-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add build and publish workflow (#279)
- build and publish workflow - publish on merge to main only - setting image name to add `-latest` suffix to test GHA access to GHCR
- Loading branch information
1 parent
fe5bdee
commit 908a712
Showing
1 changed file
with
43 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,43 @@ | ||
name: BuildImage | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 'Checkout GitHub Action' | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get Version | ||
id: version | ||
run: | | ||
echo "TAG_VERSION=$(cat pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV | ||
- name: 'Build Image' | ||
id: build | ||
run: | | ||
docker build -t ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management-latest:latest -f Dockerfile . | ||
docker tag ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management-latest:latest ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management:${{env.TAG_VERSION}} | ||
docker tag ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management-latest:latest ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management:${{env.TAG_VERSION}}_${{github.run_number}}.${{github.run_attempt}} | ||
- name: 'Login to GitHub Container Registry' | ||
id: login | ||
uses: docker/login-action@v3 | ||
if: github.ref == 'refs/heads/main' && steps.build.conclusion == 'success' | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
|
||
- name: 'Publish Image' | ||
id: publish | ||
if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success' | ||
run: | | ||
docker push ghcr.io/cfpb/regtech/sbl/regtech-user-fi-management --all-tags | ||