Skip to content

Merge pull request #20 from uw-it-aca/develop #40

Merge pull request #20 from uw-it-aca/develop

Merge pull request #20 from uw-it-aca/develop #40

Workflow file for this run

---
name: Build, Test and Deploy
env:
RELEASE_NAME: uw-postfix
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
types: [opened, reopened, synchronize]
jobs:
context:
runs-on: ubuntu-22.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-22.04
needs: context
steps:
- name: Checkout Repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
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@v2
with:
target: uw-postfix
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: Create Tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ needs.context.outputs.commit_hash }}",
sha: context.sha
})
- name: Push Image to GCR
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 }}