Skip to content

sync go mod (#1675) #1106

sync go mod (#1675)

sync go mod (#1675) #1106

Workflow file for this run

name: Deploy to Cloud Run
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
if: github.repository == 'chainguard-dev/edu'
permissions:
id-token: write # federates with GCP
steps:
- name: 'Github Actions Runner'
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- name: 'Checkout default branch to $GITHUB_WORKSPACE dir'
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3
- uses: actions/setup-node@2fddd8803e2f5c9604345a0b591c3020ee971a93 # v3
with:
node-version: 16
- name: Update themes
run: git submodule update --init --recursive
- name: npm install
run: npm install
- name: npm run build
run: npm run build
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@71fee32a0bb7e97b4d33d548e7d957010649d8fa # v0
with:
token_format: 'access_token'
project_id: '${{ secrets.PROJECT_ID }}'
workload_identity_provider: '${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.GCP_SERVICE_ACCOUNT }}'
- name: Docker Auth
id: docker-auth
uses: 'docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446' # v2
with:
username: 'oauth2accesstoken'
password: '${{ steps.auth.outputs.access_token }}'
registry: '${{ secrets.REGISTRY_URL }}'
- name: Build and push
uses: 'docker/build-push-action@15560696de535e4014efeff63c48f16952e52dd1' # v3
with:
context: .
push: true
tags: '${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/${{ secrets.SERVICE }}:${{ github.sha }}'
# Attempt to deploy the terraform configuration
- uses: hashicorp/setup-terraform@651471c36a6092792c552e8b1bef71e592b462d8 # v2.0.0
with:
terraform_version: 1.6
- env:
TF_VAR_image: '${{ secrets.REGISTRY_URL }}/${{ secrets.PROJECT_ID }}/${{ secrets.REPOSITORY }}/${{ secrets.SERVICE }}:${{ github.sha }}'
TF_VAR_project_id: ${{ secrets.PROJECT_ID }}
working-directory: ./iac
run: |
terraform init
terraform plan
terraform apply -auto-approve
- name: Post failure notice to Slack
uses: rtCamp/action-slack-notify@4e5fb42d249be6a45a298f3c9543b111b02f7907 # v2.3.0
if: ${{ failure() }}
env:
SLACK_ICON: http://github.com/chainguard-dev.png?size=48
SLACK_USERNAME: guardian
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: 'alerts-edu'
SLACK_COLOR: '#8E1600'
MSG_MINIMAL: 'true'
SLACK_TITLE: 'Deploy to cloud run failed - ${{ github.repository }}'
SLACK_MESSAGE: |
For detailed logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}