Feature/63 build and publish images #5
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
name: Build Images | |
on: | |
pull_request: | |
workflow_run: | |
workflows: ["Coverage"] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
#if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
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-mail-api:latest -f Dockerfile . | |
docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }} | |
docker tag ghcr.io/cfpb/regtech/sbl/regtech-mail-api:latest ghcr.io/cfpb/regtech/sbl/regtech-mail-api:${{ steps.version.outputs.TAG_VERSION }}_${{github.run_attempt}} | |
- name: 'Login to GitHub Container Registry' | |
id: login | |
uses: docker/login-action@v3 | |
if: 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-mail-api --all-tags | |