Deploy #484
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_run: | |
workflows: [CI] | |
branches: [main] | |
types: | |
- completed | |
env: | |
IMAGE_NAME: obr-web | |
GH_REGISTRY: ghcr.io | |
GH_ORGANIZATION: digris | |
GCP_PROJECT_ID: open-broadcast | |
GCP_SERVICE: obr-web | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
if: github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# prepare github | |
- name: Authorize github container registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.GH_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# prepare GCP | |
- name: GCP auth | |
uses: google-github-actions/auth@v0 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up cloud SDK | |
uses: google-github-actions/setup-gcloud@v0 | |
with: | |
project_id: ${{ env.GCP_PROJECT_ID }} | |
- name: Authorize GCP container registry | |
run: gcloud auth configure-docker | |
# build & push image | |
- name: Set up docker buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set outputs | |
id: vars | |
#run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Extract metadata (tags, labels) for image | |
id: meta | |
uses: docker/metadata-action@v2 | |
with: | |
images: | | |
${{ env.GH_REGISTRY }}/${{ env.GH_ORGANIZATION }}/${{ env.IMAGE_NAME }} | |
gcr.io/${{ env.GCP_PROJECT_ID }}/${{ env.GCP_SERVICE }} | |
tags: | | |
type=ref,event=branch | |
type=sha | |
type=semver,pattern={{version}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
# https://github.com/docker/buildx/issues/1533 | |
provenance: false | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
GIT_SHORT_SHA=${{ steps.vars.outputs.sha_short }} | |
- name: Deploy to GCP cloud run | |
run: gcloud builds submit --config gcp/migrate-deploy.yaml --timeout=1200 --async | |
- name: Inform slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{ | |
"text": "openbroadcast.ch - deploying ${{ steps.vars.outputs.sha_short }}" | |
} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
sentry-release: | |
needs: [deploy] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Set variables | |
id: vars | |
run: echo "version=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- run: echo ${{ steps.vars.outputs.version }} | |
- run: | | |
npm install -g yarn | |
yarn install | |
yarn build | |
- name: Create Sentry release | |
uses: getsentry/action-release@v1 | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
with: | |
environment: production | |
version: ${{ steps.vars.outputs.version }} | |
sourcemaps: './build' |