build: use setup-buildx-action in docker workflow
This commit is contained in:
parent
55b13e25df
commit
f8a4bed529
3 changed files with 28 additions and 58 deletions
29
.github/workflows/docker-build.yaml
vendored
29
.github/workflows/docker-build.yaml
vendored
|
@ -1,29 +0,0 @@
|
||||||
name: Build Docker Image
|
|
||||||
on: [push, pull_request]
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Set up Checkout
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Install Buildx and QEMU
|
|
||||||
run: |
|
|
||||||
export DOCKER_BUILDKIT=1
|
|
||||||
docker build --platform=local -o . git://github.com/docker/buildx
|
|
||||||
mkdir -p ~/.docker/cli-plugins
|
|
||||||
mv buildx ~/.docker/cli-plugins/docker-buildx
|
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
|
|
||||||
docker buildx create --use --name build --node build --driver-opt network=host
|
|
||||||
- name: Build Docker image
|
|
||||||
env:
|
|
||||||
DOCKER_USERNAME: ${{ github.actor }}
|
|
||||||
DOCKER_IMAGE_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64
|
|
||||||
REPOSITORY_NAME: ${{ github.repository }}
|
|
||||||
run: |
|
|
||||||
IFS='/' read -ra repository_name_array <<<"$REPOSITORY_NAME"
|
|
||||||
DOCKER_IMAGE_NAME=$(echo $DOCKER_USERNAME/${repository_name_array[1]} | tr '[:upper:]' '[:lower:]')
|
|
||||||
docker buildx build \
|
|
||||||
--platform "$DOCKER_IMAGE_PLATFORM" \
|
|
||||||
--output "type=image,push=false" \
|
|
||||||
--tag "$DOCKER_IMAGE_NAME":latest \
|
|
||||||
--file ./Dockerfile .
|
|
|
@ -1,44 +1,35 @@
|
||||||
# require the secrets DOCKER_HUB_PASSWORD
|
name: Build Docker Image
|
||||||
|
on: [push]
|
||||||
name: Release Docker Image
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- v*
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Run tests
|
|
||||||
run: |
|
|
||||||
if [ -f docker-compose.test.yml ]; then
|
|
||||||
docker-compose --file docker-compose.test.yml build
|
|
||||||
docker-compose --file docker-compose.test.yml run sut
|
|
||||||
else
|
|
||||||
docker build . --file Dockerfile
|
|
||||||
fi
|
|
||||||
push:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.event_name == 'push'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Checkout
|
- name: Set up Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Buildx and QEMU
|
- name: Set up QEMU
|
||||||
run: |
|
uses: docker/setup-qemu-action@v1
|
||||||
export DOCKER_BUILDKIT=1
|
with:
|
||||||
docker build --platform=local -o . git://github.com/docker/buildx
|
platforms: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
mkdir -p ~/.docker/cli-plugins
|
- name: Set up Docker Buildx
|
||||||
mv buildx ~/.docker/cli-plugins/docker-buildx
|
id: buildx
|
||||||
docker run --rm --privileged multiarch/qemu-user-static:latest --reset -p yes --credential yes
|
uses: docker/setup-buildx-action@v1
|
||||||
docker buildx create --use --name build --node build --driver-opt network=host
|
with:
|
||||||
|
version: latest
|
||||||
|
- name: Builder instance name
|
||||||
|
run: echo ${{ steps.buildx.outputs.name }}
|
||||||
|
- name: Available platforms
|
||||||
|
run: echo ${{ steps.buildx.outputs.platforms }}
|
||||||
|
|
||||||
- name: Log in to Docker Hub
|
- name: Log in to Docker Hub
|
||||||
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
DOCKER_USERNAME: ${{ github.actor }}
|
DOCKER_USERNAME: ${{ github.actor }}
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
||||||
run: |
|
run: |
|
||||||
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
echo "${DOCKER_PASSWORD}" | docker login --username ${DOCKER_USERNAME} --password-stdin
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
|
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
DOCKER_USERNAME: ${{ github.actor }}
|
DOCKER_USERNAME: ${{ github.actor }}
|
||||||
DOCKER_IMAGE_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64
|
DOCKER_IMAGE_PLATFORM: linux/amd64,linux/arm/v7,linux/arm64
|
||||||
|
@ -53,3 +44,10 @@ jobs:
|
||||||
--tag "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_VERSION" \
|
--tag "$DOCKER_IMAGE_NAME":"$DOCKER_IMAGE_VERSION" \
|
||||||
--tag "$DOCKER_IMAGE_NAME":latest \
|
--tag "$DOCKER_IMAGE_NAME":latest \
|
||||||
--file ./Dockerfile .
|
--file ./Dockerfile .
|
||||||
|
|
||||||
|
- name: Send Notification
|
||||||
|
uses: haishanh/actions-telegram-notification@v1
|
||||||
|
if: ${{ always() }}
|
||||||
|
with:
|
||||||
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
||||||
|
job-status: ${{ job.status }}
|
1
.github/workflows/push.yml
vendored
1
.github/workflows/push.yml
vendored
|
@ -57,6 +57,7 @@ jobs:
|
||||||
|
|
||||||
- name: Send Notification
|
- name: Send Notification
|
||||||
uses: haishanh/actions-telegram-notification@v1
|
uses: haishanh/actions-telegram-notification@v1
|
||||||
|
if: ${{ always() }}
|
||||||
with:
|
with:
|
||||||
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
notification-token: ${{ secrets.TG_NOTIFICATION_TOKEN }}
|
||||||
job-status: ${{ job.status }}
|
job-status: ${{ job.status }}
|
||||||
|
|
Loading…
Reference in a new issue