Deploy #152
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: | |
- dev | |
- test | |
- prod | |
release: | |
types: | |
- published | |
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.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }} | |
cancel-in-progress: true | |
jobs: | |
# test: | |
# uses: ./.github/workflows/run-tests.yml | |
# if: github.event_name == 'release' | |
# deploy: | |
# needs: test | |
# # !cancelled() is needed because if the whole workflow was cancelled, we don't want this job to run. | |
# # (github.event_name != 'release' || needs.test.result == 'success') is needed because if `test` did run, we only want this to run if `test` succeeded. | |
# if: (!cancelled() && (github.event_name != 'release' || needs.test.result == 'success')) | |
# runs-on: ubuntu-latest | |
# environment: ${{ github.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }} | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# - uses: actions/setup-python@v4 | |
# with: | |
# python-version-file: .github/workflows/.python-version | |
# cache: pip | |
# cache-dependency-path: "**/pyproject.toml" | |
# - name: Create /static directory | |
# run: mkdir -p eligibility_server/static | |
# - name: Write python packages to file | |
# run: | | |
# python -m venv .venv | |
# source .venv/bin/activate | |
# pip install pipdeptree | |
# pip install -e . | |
# pipdeptree | |
# pipdeptree >> eligibility_server/static/requirements.txt | |
# - name: Write commit SHA to file | |
# run: echo "${{ github.sha }}" >> eligibility_server/static/sha.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.event_name != 'release' && github.ref_name || github.event.release.prerelease && 'test' || 'prod' }} | |
# ghcr.io/${{ github.repository }}:${{ github.ref_name }} | |
# ghcr.io/${{ github.repository }}:${{ github.sha }} | |
deploy-infra: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Trigger Azure DevOps pipeline' | |
uses: Azure/pipelines@v1.2 | |
with: | |
azure-devops-project-url: 'https://dev.azure.com/sbmtd/eligibility-server' | |
azure-pipeline-name: 'cal-itp.eligibility-server' # name of the Azure pipeline to be triggered, required | |
azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}' # required field | |
azure-pipeline-variables: '{"variable1": "value1", "variable2": "value2"}' # optional stringified json |