generated from cfpb/open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (36 loc) · 1.4 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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/sbl-filing-api-latest:latest -f Dockerfile .
docker tag ghcr.io/cfpb/regtech/sbl/sbl-filing-api-latest:latest ghcr.io/cfpb/regtech/sbl/sbl-filing-api:${{env.TAG_VERSION}}
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}}
- 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/sbl-filing-api-latest --all-tags