From 4da43d2651e85f07f6b69d577d9d96ccb1afb0a3 Mon Sep 17 00:00:00 2001 From: Eran Davidovich Date: Wed, 22 Dec 2021 16:39:44 +0200 Subject: [PATCH] feat: simultaneously build p2w-relay/attest. also use meta to tag the image. --- ...-image.yml => docker-image-p2w-attest.yml} | 30 ++++++------- .github/workflows/docker-image-p2w-relay.yml | 45 +++++++++++++++++++ 2 files changed, 59 insertions(+), 16 deletions(-) rename .github/workflows/{docker-image.yml => docker-image-p2w-attest.yml} (53%) create mode 100644 .github/workflows/docker-image-p2w-relay.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image-p2w-attest.yml similarity index 53% rename from .github/workflows/docker-image.yml rename to .github/workflows/docker-image-p2w-attest.yml index 50c32e2c..d129ba54 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image-p2w-attest.yml @@ -1,10 +1,14 @@ -name: build docker image +name: build attest docker image on: push: + branches: + - "master" tags: - "v*" pull_request: + branches: + - "master" jobs: docker: @@ -13,14 +17,17 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Set outputs - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/p2w-attest - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to DockerHub + if: github.event_name != 'pull_request' uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -30,18 +37,9 @@ jobs: uses: docker/build-push-action@v2 with: platforms: linux/amd64 - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/p2w-attest:${{ steps.vars.outputs.sha_short }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} target: p2w-attest cache-from: type=gha cache-to: type=gha,mode=max - - - name: Build and push p2w-relay - uses: docker/build-push-action@v2 - with: - platforms: linux/amd64 - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/p2w-relay:${{ steps.vars.outputs.sha_short }} - target: p2w-relay - cache-from: type=gha - cache-to: type=gha,mode=max diff --git a/.github/workflows/docker-image-p2w-relay.yml b/.github/workflows/docker-image-p2w-relay.yml new file mode 100644 index 00000000..e321232f --- /dev/null +++ b/.github/workflows/docker-image-p2w-relay.yml @@ -0,0 +1,45 @@ +name: build relay docker image + +on: + push: + branches: + - "master" + tags: + - "v*" + pull_request: + branches: + - "master" + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ secrets.DOCKERHUB_USERNAME }}/p2w-relay + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to DockerHub + if: github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push p2w-relay + uses: docker/build-push-action@v2 + with: + platforms: linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: p2w-relay + cache-from: type=gha + cache-to: type=gha,mode=max