Created
March 17, 2022 12:57
-
-
Save thclark/9a0c57594e1f7eef08c9763f2098d83e to your computer and use it in GitHub Desktop.
Sketch of what a set of octue github actions would look like
This file contains hidden or 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: octue | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
octue: | |
runs-on: ubuntu-latest | |
timeout-minutes: 60 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Get Version | |
uses: octue/get-version@v1 | |
from: package.json | |
# Replaces: | |
# - name: Get Version | |
# id: get-version | |
# run: | | |
# PACKAGE_VERSION=$(node -p -e "require('./package.json').version") | |
# echo "::set-output name=version::${PACKAGE_VERSION}" | |
# - name: Convert branch name to tag | |
# # Get the github ref as a slugified docker tag | |
# id: branch | |
# run: echo "::set-output name=branch_tag::$(echo ${GITHUB_REF#refs/heads/} | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+//g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$//g' | tr A-Z a-z)" | |
- name: Check Version | |
if: # If it's a PR into main, otherwise skip check | |
uses: octue/check-version@v1 | |
- name: Build | |
uses: octue/build-python@v1 | |
# Does stuff like: | |
# - name: Set up QEMU | |
# uses: docker/setup-qemu-action@v1 | |
# - name: Set up Docker Buildx | |
# uses: docker/setup-buildx-action@v1 | |
# - name: Build | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: . | |
# platforms: linux/amd64 | |
# file: .gcloud/api/Dockerfile | |
# load: true # Load built image into the docker engine ready for test... | |
# push: false # ...but don't push it until after test success | |
# tags: api:test | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
- name: Deploy | |
uses: octue/deploy-gcp@v1 | |
region: europe-west-1 | |
kind: cloud-run # or cloud-function, dataflow, compute-engine | |
project: project-name | |
options: | |
- machine: m1-small | |
cpus: 26 | |
memory: 6 #gb | |
# Does stuff like | |
# - name: Authenticate with GCP Workload Identity | |
# id: auth | |
# uses: google-github-actions/[email protected] | |
# with: | |
# # NOTE: If setting create_credentials_file=true, .dockerignore file must include `gha-creds-*.json` to avoid baking these credentials into build | |
# create_credentials_file: true | |
# workload_identity_provider: projects/506632032451/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider | |
# service_account: [email protected] | |
# - name: Setup gcloud | |
# uses: "google-github-actions/setup-gcloud@v0" | |
# - name: Configure Docker for GCP | |
# run: gcloud auth configure-docker europe-west1-docker.pkg.dev | |
# - name: Push main container with latest and version tags | |
# if: ${{ github.event_name == 'push' && steps.branch.outputs.branch_tag == 'main'}} | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: . | |
# platforms: linux/amd64 | |
# file: .gcloud/api/Dockerfile | |
# push: true | |
# tags: | | |
# europe-west1-docker.pkg.dev/project-name/api/api:latest | |
# europe-west1-docker.pkg.dev/project-name/api/api:${{steps.version.outputs.version}} | |
# build-args: | | |
# PERSONAL_ACCESS_TOKEN_GITHUB=${{ secrets.PACKAGE_TOKEN_GITHUB }} | |
# - name: Push branch container with latest tag | |
# if: ${{ github.event_name != 'push' || steps.branch.outputs.branch_tag != 'main'}} | |
# uses: docker/build-push-action@v2 | |
# with: | |
# context: . | |
# platforms: linux/amd64 | |
# file: .gcloud/api/Dockerfile | |
# push: true | |
# tags: europe-west1-docker.pkg.dev/project-name/api/api:${{ steps.branch.outputs.branch_tag}}-latest | |
# | |
# - Then invoke terraform to deploy etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment