From 2084f8d0216ef0d24816f71a0cac8918cbb2836d Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:26:17 -0700 Subject: [PATCH 1/9] Add Build and push Docker Action --- .github/workflows/build_and_push_docker.yml | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build_and_push_docker.yml diff --git a/.github/workflows/build_and_push_docker.yml b/.github/workflows/build_and_push_docker.yml new file mode 100644 index 0000000..630b5f1 --- /dev/null +++ b/.github/workflows/build_and_push_docker.yml @@ -0,0 +1,41 @@ +name: Build and push Docker image + +on: + push + +jobs: + build: + runs-on: ubuntu-latest + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Test + run: | + docker run --rm ${{ env.TEST_TAG }} + - + name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false + tags: | + thejf/antennas:test + ghcr.io/jfarseneau/antennas:test From f3d812a3d44f344dede6a3bd3fff08ab21de2fa0 Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:27:55 -0700 Subject: [PATCH 2/9] Kebab-case GH Action and fix syntax --- ...h_docker.yml => build-and-push-docker.yml} | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) rename .github/workflows/{build_and_push_docker.yml => build-and-push-docker.yml} (72%) diff --git a/.github/workflows/build_and_push_docker.yml b/.github/workflows/build-and-push-docker.yml similarity index 72% rename from .github/workflows/build_and_push_docker.yml rename to .github/workflows/build-and-push-docker.yml index 630b5f1..14f9ce6 100644 --- a/.github/workflows/build_and_push_docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -6,31 +6,25 @@ on: jobs: build: runs-on: ubuntu-latest - - - name: Set up QEMU + - name: Set up QEMU uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login to GitHub Container Registry + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Test + - name: Test run: | docker run --rm ${{ env.TEST_TAG }} - - - name: Build and push + - name: Build and push uses: docker/build-push-action@v2 with: context: . @@ -38,4 +32,4 @@ jobs: push: false tags: | thejf/antennas:test - ghcr.io/jfarseneau/antennas:test + ghcr.io/jfarseneau/antennas:test \ No newline at end of file From c2bcc9cea6dcda84d49e19eba0549e78644f040a Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:29:12 -0700 Subject: [PATCH 3/9] Add steps to GitHub Actions workflow --- .github/workflows/build-and-push-docker.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index 14f9ce6..2fe8a86 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -6,6 +6,7 @@ on: jobs: build: runs-on: ubuntu-latest + steps: - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx From 6a7df1e5a884c9baf5a91a465ab58a238aaad739 Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:30:45 -0700 Subject: [PATCH 4/9] Remove test tag for now --- .github/workflows/build-and-push-docker.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index 2fe8a86..f237277 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -22,9 +22,6 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Test - run: | - docker run --rm ${{ env.TEST_TAG }} - name: Build and push uses: docker/build-push-action@v2 with: From 4c2aa92b4e1330b8a3e61c09f506a24fb5b3e460 Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:32:25 -0700 Subject: [PATCH 5/9] Checkout registry before trying to build it --- .github/workflows/build-and-push-docker.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index f237277..76fef6a 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -7,21 +7,28 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up QEMU uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push uses: docker/build-push-action@v2 with: From 669a85140d85a96e22b343eae9663f5454db5c0f Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:42:53 -0700 Subject: [PATCH 6/9] Add RPi as target for building --- .github/workflows/build-and-push-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index 76fef6a..bff8640 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -33,7 +33,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm64,linux/arm/v6 push: false tags: | thejf/antennas:test From 36116bd4f690494e1840b552b297e4b2dfbd7ffb Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:47:50 -0700 Subject: [PATCH 7/9] Add arm/v7 as well for good measure --- .github/workflows/build-and-push-docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index bff8640..28e4176 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -33,7 +33,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platforms: linux/amd64,linux/arm64,linux/arm/v6 + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 push: false tags: | thejf/antennas:test From 150fe413bf7de619a0dc025d0453dc59d845f71d Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 13:58:29 -0700 Subject: [PATCH 8/9] Switch to automatic tag build --- .github/workflows/build-and-push-docker.yml | 34 ++++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index 28e4176..9aded7c 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -1,7 +1,16 @@ name: Build and push Docker image on: - push + schedule: + - cron: '0 10 * * *' + push: + branches: + - '**' + tags: + - 'v*.*.*' + pull_request: + branches: + - 'main' jobs: build: @@ -10,6 +19,22 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + thejf/antennas + ghcr.io/jfarseneau/antennas + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + - name: Set up QEMU uses: docker/setup-qemu-action@v1 @@ -34,7 +59,6 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 - push: false - tags: | - thejf/antennas:test - ghcr.io/jfarseneau/antennas:test \ No newline at end of file + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 42223d0b25b85a416697efc6efd8ab7f8e59a08e Mon Sep 17 00:00:00 2001 From: Jean-Francois Arseneau Date: Fri, 15 Apr 2022 14:05:36 -0700 Subject: [PATCH 9/9] Remove build tags we don't want --- .github/workflows/build-and-push-docker.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/build-and-push-docker.yml b/.github/workflows/build-and-push-docker.yml index 9aded7c..73207ae 100644 --- a/.github/workflows/build-and-push-docker.yml +++ b/.github/workflows/build-and-push-docker.yml @@ -1,11 +1,7 @@ name: Build and push Docker image on: - schedule: - - cron: '0 10 * * *' push: - branches: - - '**' tags: - 'v*.*.*' pull_request: @@ -27,13 +23,10 @@ jobs: thejf/antennas ghcr.io/jfarseneau/antennas tags: | - type=schedule - type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - type=sha - name: Set up QEMU uses: docker/setup-qemu-action@v1