dupe metrics def #443
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, Test and Deploy | |
env: | |
RELEASE_NAME: mailman-core | |
on: | |
push: | |
branches: [main, develop] | |
pull_request: | |
branches: [main, develop] | |
types: [opened, reopened, synchronize] | |
jobs: | |
context: | |
runs-on: ubuntu-20.04 | |
outputs: | |
commit_hash: ${{ steps.context.outputs.commit_hash }} | |
git_repo_branch: ${{ steps.context.outputs.git_repo_branch }} | |
image_tag: ${{ steps.context.outputs.image_tag }} | |
steps: | |
- name: Set up Context | |
id: context | |
uses: uw-it-aca/actions/cicd-context@main | |
with: | |
release_name: ${{ env.RELEASE_NAME }} | |
build: | |
runs-on: ubuntu-20.04 | |
needs: context | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-$(echo ${{ hashFiles('Dockerfile') }} | head -c 16) | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Build App Image | |
uses: docker/build-push-action@v3 | |
with: | |
target: uw-mailman-core | |
tags: ${{ needs.context.outputs.image_tag }} | |
push: false | |
load: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Push Image to GAR | |
if: github.event_name == 'push' | |
uses: uw-it-aca/actions/gcr-push@main | |
with: | |
image_tag: ${{ needs.context.outputs.image_tag }} | |
gcp_json_key: ${{ secrets.GCP_JSON_KEY }} | |
deploy: | |
if: github.event_name == 'push' | |
needs: [context, build] | |
runs-on: ubuntu-20.04 | |
outputs: | |
context: ${{ steps.context.outputs.context }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Develop Deployment Pipeline | |
if: >- | |
contains(fromJSON('["develop"]'), | |
needs.context.outputs.git_repo_branch) | |
uses: uw-it-aca/actions/cicd-deploy@main | |
with: | |
release_name: ${{ env.RELEASE_NAME }} | |
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }} | |
commit_hash: ${{ needs.context.outputs.commit_hash }} | |
git_repo_branch: ${{ needs.context.outputs.git_repo_branch }} | |
- name: Main Deployment Pipeline | |
if: >- | |
contains(fromJSON('["main"]'), | |
needs.context.outputs.git_repo_branch) | |
uses: uw-it-aca/actions/cicd-deploy@main | |
with: | |
release_name: ${{ env.RELEASE_NAME }} | |
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }} | |
commit_hash: ${{ needs.context.outputs.commit_hash }} | |
git_repo_branch: ${{ needs.context.outputs.git_repo_branch }} | |
gcp_production_project: 'uwit-mci-0016' | |
gcp_production_flux_instance: 'mailman' | |
flux_repo_default_branch: 'main' | |
- name: 'Surface context from executed build step' | |
id: context | |
shell: bash | |
run: echo "context=$(< ${CONTEXT_FILENAME})" >> $GITHUB_OUTPUT | |
housekeeping: | |
if: github.event_name == 'push' | |
needs: [context, build, deploy] | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: House Keeping | |
uses: uw-it-aca/actions/cicd-housekeeping@main | |
with: | |
release_name: ${{ env.RELEASE_NAME }} | |
gh_auth_token: ${{ secrets.GH_AUTH_TOKEN }} | |
registry_password: ${{ secrets.GCP_JSON_KEY }} | |
context: ${{ needs.deploy.outputs.context }} | |
flux_instances: 'mailman,dev' |