release-published #208
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: Build and push Docker image | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: [release-published] | |
env: | |
RELEASE_VERSION: v${{ github.event.client_payload.version }} | |
TAG_VERSION: ghcr.io/${{ github.repository_owner }}/backstage:${{ github.event.client_payload.version }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Harden Runner | |
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 | |
with: | |
egress-policy: audit | |
- name: checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
path: backstage | |
ref: ${{ github.event.client_payload.version && env.RELEASE_VERSION || github.ref }} | |
- name: use node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
registry-url: https://registry.npmjs.org/ # Needed for auth | |
- name: yarn install | |
uses: backstage/actions/yarn-install@25145dd4117d50e1da9330e9ed2893bc6b75373e # v0.6.15 | |
with: | |
cache-prefix: ${{ runner.os }}-v${{ matrix.node-version }} | |
- name: create-app | |
run: npx @backstage/create-app | |
env: | |
BACKSTAGE_APP_NAME: example-app | |
YARN_ENABLE_IMMUTABLE_INSTALLS: false | |
- name: yarn build | |
run: yarn build:backend | |
working-directory: ./example-app | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 | |
- name: Build and push | |
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 | |
with: | |
context: './example-app' | |
file: ./example-app/packages/backend/Dockerfile | |
push: ${{ (github.event_name == 'repository_dispatch') && (github.event.action == 'release-published') }} | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/backstage:latest | |
${{ github.event.client_payload.version && env.TAG_VERSION || '' }} | |
labels: | | |
org.opencontainers.image.description=Docker image generated from the latest Backstage release; this contains what you would get out of the box by running npx @backstage/create-app and building a Docker image from the generated source. This is meant to ease the process of evaluating Backstage for the first time, but also has the severe limitation that there is no way to install additional plugins relevant to your infrastructure. |