From 55efe4f8b0fdfc655e6207cbca5dd84eab0a937a Mon Sep 17 00:00:00 2001 From: Diwank Singh Tomer Date: Sat, 28 Sep 2024 12:21:30 -0400 Subject: [PATCH] fix: Minor fix to docker bake github actions (#529) - **GitHub Actions**: - Add `docker-bake-on-pr.yml` for baking images on pull requests. - Rename `dev-push-to-hub.yml` to `bake-push-to-hub.yml` and `main-push-to-hub.yml` to `latest-push-to-hub.yml`. - Update `bake-push-to-hub.yml` and `latest-push-to-hub.yml` to use `docker/bake-action@v5` and remove branch name and git sha setting steps. --- ...v-push-to-hub.yml => bake-push-to-hub.yml} | 17 ++++---- .github/workflows/docker-bake-on-pr.yml | 39 +++++++++++++++++++ ...push-to-hub.yml => latest-push-to-hub.yml} | 12 ++---- 3 files changed, 50 insertions(+), 18 deletions(-) rename .github/workflows/{dev-push-to-hub.yml => bake-push-to-hub.yml} (64%) create mode 100644 .github/workflows/docker-bake-on-pr.yml rename .github/workflows/{main-push-to-hub.yml => latest-push-to-hub.yml} (76%) diff --git a/.github/workflows/dev-push-to-hub.yml b/.github/workflows/bake-push-to-hub.yml similarity index 64% rename from .github/workflows/dev-push-to-hub.yml rename to .github/workflows/bake-push-to-hub.yml index f92a8bc2c..eb6dd9168 100644 --- a/.github/workflows/dev-push-to-hub.yml +++ b/.github/workflows/bake-push-to-hub.yml @@ -5,6 +5,8 @@ on: push: branches: - "dev" + tags: + - "v*" jobs: Bake-Push-Images: @@ -13,12 +15,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set branch name - id: variables - run: | - echo "branch_name=$(echo ${GITHUB_REF#refs/heads/} | tr '/' '-')" >> $GITHUB_OUTPUT - echo "git_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -29,7 +25,7 @@ jobs: password: "${{ secrets.DOCKER_HUB_PASSWORD }}" - name: Build and push agent images - uses: docker/bake-action@v3 + uses: docker/bake-action@v5 with: files: | ./docker-bake.hcl @@ -38,9 +34,10 @@ jobs: set: | *.cache-from=type=gha *.cache-to=type=gha,mode=max - *.args.TAG=${{ steps.variables.outputs.branch_name }} - *.args.GIT_SHA=${{ steps.variables.outputs.git_sha }} + env: + TAG: ${{ github.ref_name }} + GIT_SHA: ${{ github.sha }} concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: ${{ github.ref != 'refs/heads/dev' }} + cancel-in-progress: true diff --git a/.github/workflows/docker-bake-on-pr.yml b/.github/workflows/docker-bake-on-pr.yml new file mode 100644 index 000000000..2e00f0929 --- /dev/null +++ b/.github/workflows/docker-bake-on-pr.yml @@ -0,0 +1,39 @@ +name: Bake images on PR +run-name: ${{ github.actor }} is baking images + +on: + pull_request: + +jobs: + Bake-Images: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: julepai + password: "${{ secrets.DOCKER_HUB_PASSWORD }}" + + - name: Bake images + uses: docker/bake-action@v5 + with: + files: | + ./docker-bake.hcl + targets: agents-api + push: false + set: | + *.cache-from=type=gha + *.cache-to=type=gha,mode=max + env: + TAG: pr-run-${{ github.run_number }}-${{ github.run_attempt }} + GIT_SHA: ${{ github.sha }} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} diff --git a/.github/workflows/main-push-to-hub.yml b/.github/workflows/latest-push-to-hub.yml similarity index 76% rename from .github/workflows/main-push-to-hub.yml rename to .github/workflows/latest-push-to-hub.yml index 8b0fffe89..3853a8faa 100644 --- a/.github/workflows/main-push-to-hub.yml +++ b/.github/workflows/latest-push-to-hub.yml @@ -13,11 +13,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set git sha - id: variables - run: | - echo "git_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -28,7 +23,7 @@ jobs: password: "${{ secrets.DOCKER_HUB_PASSWORD }}" - name: Build and push agent images - uses: docker/bake-action@v3 + uses: docker/bake-action@v5 with: files: | ./docker-bake.hcl @@ -37,8 +32,9 @@ jobs: set: | *.cache-from=type=gha *.cache-to=type=gha,mode=max - *.args.TAG=latest - *.args.GIT_SHA=${{ steps.variables.outputs.git_sha }} + env: + TAG: latest + GIT_SHA: ${{ github.sha }} concurrency: group: ${{ github.workflow }}-${{ github.ref }}