Skip to content

fix(ci): syntax error #218

fix(ci): syntax error

fix(ci): syntax error #218

Workflow file for this run

name: Deploy
on:
workflow_dispatch:
push:
branches:
- dev
- test
- prod
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
with:
fetch-depth: 0
fetch-tags: true
- name: Git describe (1)
run: |
git describe
git describe --long
- uses: actions/setup-python@v5
with:
python-version-file: .github/workflows/.python-version
# - name: Create /static directory
# run: mkdir -p static
- name: Echo commit SHA
run: echo "${{ github.sha }}"
- name: Echo version
run: echo "${{ github.ref_name }}"
- name: Write python packages to file
run: |
python -m venv .venv
source .venv/bin/activate
pip install pipdeptree setuptools_scm
pip install -e .
python -m setuptools_scm
pipdeptree
- name: Git describe (2)
run: |
git describe
git describe --long
# - 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 }}