-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding ghcr.io container building action
- Loading branch information
1 parent
ee43e0c
commit 0f58983
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: CD | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
release: | ||
types: | ||
- published | ||
concurrency: | ||
# Only run the latest workflow. | ||
# If a build is already happening, cancel it to avoid a race | ||
# condition where an older image overwrites a newer one. | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: true | ||
jobs: | ||
build: | ||
name: Build [batai] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Generate image tags | ||
uses: actions/github-script@v6 | ||
id: image-tags | ||
with: | ||
result-encoding: string | ||
script: | | ||
const image = 'ghcr.io/${{ github.repository }}'.toLowerCase(); | ||
let tags = `${image}/batai:latest`; | ||
if ('${{ github.ref }}'.startsWith('refs/tags/v')) { | ||
tags += `,${image}/batai:${{ github.ref_name }}`; | ||
} | ||
return tags; | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{ steps.image-tags.outputs.result }} |