Merge pull request #11696 from backstage/timbonicush/default-docker-image

Build default Docker image on release
This commit is contained in:
Fredrik Adelöw
2022-06-30 16:28:05 +02:00
committed by GitHub
6 changed files with 117 additions and 29 deletions
+89
View File
@@ -0,0 +1,89 @@
name: Build and push Docker Hub image
on:
repository_dispatch:
types: [release-published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: backstage
ref: v${{ github.event.client_payload.version }}
- name: setup-node
uses: actions/setup-node@v1
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
# Beginning of yarn setup, keep in sync between all workflows.
# TODO(Rugvip): move this to composite action once all features we use are supported
- name: use node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/ # Needed for auth
# Cache every node_modules folder inside the monorepo
- name: cache all node_modules
id: cache-modules
uses: actions/cache@v2
with:
path: '**/node_modules'
# We use both yarn.lock and package.json as cache keys to ensure that
# changes to local monorepo packages bust the cache.
key: ${{ runner.os }}-v${{ matrix.node-version }}-node_modules-${{ hashFiles('yarn.lock', '**/package.json') }}
# If we get a cache hit for node_modules, there's no need to bring in the global
# yarn cache or run yarn install, as all dependencies will be installed already.
- name: find location of global yarn cache
id: yarn-cache
if: steps.cache-modules.outputs.cache-hit != 'true'
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: cache global yarn cache
uses: actions/cache@v2
if: steps.cache-modules.outputs.cache-hit != 'true'
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
if: steps.cache-modules.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
# End of yarn setup
- name: create-app
run: npx @backstage/create-app
env:
BACKSTAGE_APP_NAME: example-app
- name: yarn build
run: yarn build
working-directory: ./example-app
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push
uses: docker/build-push-action@v2
with:
context: './example-app'
file: ./example-app/packages/backend/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/backstage:latest
ghcr.io/${{ github.repository_owner }}/backstage:${{ github.event.client_payload.version }}
+8 -1
View File
@@ -173,7 +173,7 @@ jobs:
# Grabs the version in the root package.json and creates a tag on GitHub
- name: Create a release tag
id: create_tag
run: node scripts/create-release-tag.js --dispatch-workflows
run: node scripts/create-release-tag.js
env:
GITHUB_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
@@ -183,6 +183,13 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
- name: Dispatch repository event
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }}
event-type: release-published
client-payload: '{"version": "${{ steps.create_tag.outputs.version }}"}'
# Notify everyone about this great new release :D
- name: Discord notification
uses: Ilshidur/action-discord@0.3.2
+5 -8
View File
@@ -1,10 +1,7 @@
name: Sync Release Manifest
on:
workflow_dispatch:
inputs:
version:
description: Version number, without any 'v' prefix
required: true
repository_dispatch:
types: [release-published]
jobs:
create-new-version:
@@ -23,7 +20,7 @@ jobs:
with:
path: backstage
# 'v' prefix is added here for the tag, we keep it out of the manifest logic
ref: v${{ github.event.inputs.version }}
ref: v${{ github.event.client_payload.version }}
# Checkout backstage/versions into /backstage/versions, which is where store the output
- name: Checkout versions
@@ -44,10 +41,10 @@ jobs:
cd backstage
mkdir -p scripts
wget -O scripts/assemble-manifest.js https://raw.githubusercontent.com/backstage/backstage/master/scripts/assemble-manifest.js
node scripts/assemble-manifest.js ${{ github.event.inputs.version }}
node scripts/assemble-manifest.js ${{ github.event.client_payload.version }}
cd versions
git add .
git commit -am "${{ github.event.inputs.version }}"
git commit -am "${{ github.event.client_payload.version }}"
git push
- name: Dispatch update-helper update