Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding ghcr.io container building action #15

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/cd.yaml
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 }}
Loading