Skip to content

Deploy backstage

Deploy backstage #85

Workflow file for this run

name: Deploy Backstage
on:
workflow_run:
workflows: ["CI Workflow"]
types:
- completed
jobs:
create-and-push-image:
permissions:
id-token: write
contents: read # Remove if not required
name: "Create and Push Docker Image to GAR"
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up QEMU
id: setup-qemu
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: docker-buildx-setup
uses: docker/setup-buildx-action@v3
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
#create_credentials_file: true
token_format: access_token
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_DEPLOY_SA }}
- name: Set up GCP SDK
uses: google-github-actions/setup-gcloud@v1
with:
version: "latest"
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Login to GAR
id: login-gar
uses: docker/login-action@v3
with:
registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Configure Docker for Artifact Registry
run: |
gcloud auth configure-docker \
${{ secrets.GCP_REGION }}-docker.pkg.dev
- name: Build and Push Docker Image
id: build-and-push
uses: docker/build-push-action@v5
with:
push: true
context: .
file: ./Dockerfile
platforms: linux/amd64
tags: ${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
build-args: |
APP_ENV=docker
deploy-image:
permissions:
id-token: write
contents: read # Remove if not required
name: "Deploy Image on Cloud Run"
runs-on: ubuntu-latest
needs: create-and-push-image
defaults:
run:
shell: bash
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v2
with:
create_credentials_file: true
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCP_DEPLOY_SA }}
- name: Set up GCP SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service: ${{ secrets.GCP_CLOUD_RUN_SERVICE }}
image: ${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
region: ${{ secrets.GCP_REGION }}
flags: >
--allow-unauthenticated
env_vars: |
BASE_URL=https://backstage.foundations-software-engineering.com