Skip to content

Commit

Permalink
fix: Minor fix to docker bake github actions (#529)
Browse files Browse the repository at this point in the history
  - **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.
  • Loading branch information
creatorrr committed Sep 30, 2024
1 parent ed08024 commit 55efe4f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- "dev"
tags:
- "v*"

jobs:
Bake-Push-Images:
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
39 changes: 39 additions & 0 deletions .github/workflows/docker-bake-on-pr.yml
Original file line number Diff line number Diff line change
@@ -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' }}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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 }}
Expand Down

0 comments on commit 55efe4f

Please sign in to comment.