chore(pre-commit): autoupdate hooks (#431) #244
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: Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
tags: | |
# pre-release tag | |
- "202[3-9].[0-9][0-9].[0-9]+-rc[0-9]+" | |
# release tags | |
- "202[3-9].[0-9][0-9].[0-9]+" | |
defaults: | |
run: | |
shell: bash | |
concurrency: | |
# this expression gives us the name of the deployment environment. It works like a ternary operation (see https://github.com/actions/runner/issues/409#issuecomment-727565588) | |
group: ${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
uses: ./.github/workflows/run-tests.yml | |
if: github.ref_type == 'tag' | |
deploy: | |
needs: test | |
# !cancelled() is needed because if the whole workflow was cancelled, we don't want this job to run. | |
# (github.ref_type != 'tag' || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded. | |
if: (!cancelled() && (github.ref_type != 'tag' || needs.test.result == 'success')) | |
runs-on: ubuntu-latest | |
environment: ${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version-file: .github/workflows/.python-version | |
- name: Create /static directory | |
run: mkdir -p static | |
- name: Write python packages to file | |
run: | | |
python -m pip install --upgrade pip | |
pip install pipdeptree setuptools_scm | |
pip install -e . | |
python -m setuptools_scm | |
pipdeptree >> static/requirements.txt | |
- name: Write commit SHA to file | |
run: echo "${{ github.sha }}" >> static/sha.txt | |
- name: Write version to file | |
run: echo "${{ github.ref_name }}" >> static/version.txt | |
- name: Docker Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build, tag, and push image to GitHub Container Registry | |
uses: docker/build-push-action@v5 | |
with: | |
builder: ${{ steps.buildx.outputs.name }} | |
build-args: GIT-SHA=${{ github.sha }} | |
cache-from: type=gha,scope=cal-itp | |
cache-to: type=gha,scope=cal-itp,mode=max | |
context: . | |
file: Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ github.ref_type != 'tag' && github.ref_name || contains(github.ref, '-rc') && 'test' || 'prod' }} | |
ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
ghcr.io/${{ github.repository }}:${{ github.sha }} |