Skip to content

Commit 58ead41

Browse files
authored
add build and publish workflow (#539)
- build and publish workflow - publish on merge to main only - ** do not merge until Package Settings have been changed to allow GHA write to GHCR for this repo **
1 parent 45fc7d3 commit 58ead41

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: BuildImage
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: 'Checkout GitHub Action'
14+
id: checkout
15+
uses: actions/checkout@v4
16+
17+
- name: Get Version
18+
id: version
19+
run: |
20+
echo "TAG_VERSION=$(cat pyproject.toml | grep '^version.*$' | sed 's/version = //' | tr -d '\"' )" >> $GITHUB_ENV
21+
22+
- name: 'Build Image'
23+
id: build
24+
run: |
25+
docker build -t ghcr.io/cfpb/regtech/sbl/sbl-filing-api-latest:latest -f Dockerfile .
26+
docker tag ghcr.io/cfpb/regtech/sbl/sbl-filing-api-latest:latest ghcr.io/cfpb/regtech/sbl/sbl-filing-api:${{env.TAG_VERSION}}
27+
docker tag ghcr.io/cfpb/regtech/sbl/sbl-filing-api-latest:latest ghcr.io/cfpb/regtech/sbl/sbl-filing-api:${{env.TAG_VERSION}}_${{github.run_number}}.${{github.run_attempt}}
28+
29+
- name: 'Login to GitHub Container Registry'
30+
id: login
31+
uses: docker/login-action@v3
32+
if: github.ref == 'refs/heads/main' && steps.build.conclusion == 'success'
33+
with:
34+
registry: ghcr.io
35+
username: ${{github.actor}}
36+
password: ${{secrets.GITHUB_TOKEN}}
37+
38+
- name: 'Publish Image'
39+
id: publish
40+
if: github.ref == 'refs/heads/main' && steps.login.conclusion == 'success'
41+
run: |
42+
docker push ghcr.io/cfpb/regtech/sbl/sbl-filing-api-latest --all-tags
43+

0 commit comments

Comments
 (0)