Skip to content

Commit

Permalink
Updates for release/publish workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenjohnson committed Aug 14, 2024
1 parent 7694a3c commit 1591ee9
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 195 deletions.
13 changes: 1 addition & 12 deletions .github/actions/pull-ghcr/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
name: pull-ghcr
description: Pull all from GHCR
inputs:
github_token:
description: token to access GHCR
required: true
description: Pull all images from GHCR (for current run ID)

runs:
using: composite

steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- shell: bash
run: |
set -x
Expand Down
11 changes: 1 addition & 10 deletions .github/actions/push-ghcr/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ name: push-ghcr
description: Push to GHCR
inputs:
docker_image:
description: name of the docker image to push
required: true
github_token:
description: token to access GHCR
description: name of the image to push
required: true

runs:
using: composite

steps:
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.github_token }}

- shell: bash
run: |
set -x
Expand Down
35 changes: 35 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Setup Node and Docker build environment"
description: "Reusable action to set up the environment for builds and tests"

runs:
using: "composite"
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 9.6.0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- name: Install Javascript dependencies (PNPM)
run: pnpm install

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup a Docker Buildx builder
id: builder
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
75 changes: 18 additions & 57 deletions .github/workflows/_build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
component:
imageName:
- wikibase
- elasticsearch
- wdqs
Expand All @@ -27,36 +27,10 @@ jobs:
- quickstatements

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 9.6.0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- run: pnpm install

- name: Setup QEMU
uses: docker/setup-qemu-action@v3

- name: Setup Docker Buildx
id: builder
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- uses: ./.github/actions/setup-environment

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Building ${{ matrix.component }}
run: pnpm exec nx build ${{ matrix.component }} --push
- name: Build and push ${{ matrix.imageName }}
run: pnpm exec nx build ${{ matrix.imageName }} --push

test:
needs: build
Expand All @@ -77,39 +51,26 @@ jobs:
- deploy

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 9.6.0

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'

- run: pnpm install
- uses: ./.github/actions/setup-environment

- uses: ./.github/actions/pull-ghcr
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: "Pull images from GHCR"
uses: ./.github/actions/pull-ghcr

- run: pnpm exec nx test -- ${{ matrix.suite }}
- uses: "Run ${{ matrix.suite }} test suite"
- run: pnpm exec nx test -- ${{ matrix.suite }}

- name: Show logs
run: |
ls -lahr test/suites/${{ matrix.suite }}/results test/suites/${{ matrix.suite }}/results/*
tail -n +1 test/suites/${{ matrix.suite }}/results/*.log
continue-on-error: true
- name: Show logs
run: |
ls -lahr test/suites/${{ matrix.suite }}/results test/suites/${{ matrix.suite }}/results/*
tail -n +1 test/suites/${{ matrix.suite }}/results/*.log
continue-on-error: true

- uses: actions/upload-artifact@v3
with:
name: TestResults
path: test/suites/**/results
- uses: actions/upload-artifact@v3
with:
name: TestResults
path: test/suites/**/results

test-success:
# Post-test CI step - to check all tests succeeded
# Github Branch Protection rules require this to pass to allow merging
runs-on: ubuntu-latest
needs:
- lint
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/build_and_publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 📦 Build and Publish a WBS Image Release

on:
workflow_dispatch:
inputs:
image_name:
description: 'Image to release'
type: choice
required: true
default: 'wikibase'
options:
- elasticsearch
- quickstatements
- wdqs
- wdqs-frontend
- wdqs-proxy
- wikibase
- All images with unreleased changes
dry_run:
description: "Only log what will be done, don't do it yet."
type: boolean
required: true
default: true

permissions:
contents: write
packages: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: ./.github/actions/setup-environment

- uses: docker/login-action@v3
with:
# implicitly docker hub
username: wmdetravisbot
password: ${{ secrets.WBS_PUBLISH_TOKEN }}

- name: Git tag release and publish version tagged images to Dockerhub
run: |
set -e # abort on error
set -x # show commands
git config --global user.name 'wikibase suite github actions bot'
git config --global user.email 'wikibase-suite-github-actions-bot@users.noreply.github.com'
if [ "${{ inputs.dry_run }}" == "true" ]; then
DRY_RUN_FLAG="--dry-run"
else
DRY_RUN_FLAG=""
fi
if [ "${{ inputs.image_name }}" == "All images with unreleased changes" ]; then
PROJECT_ARG=""
else
PROJECT_ARG="-p ${{ inputs.image_name }}"
fi
pnpm exec nx release publish $PROJECT_ARG $DRY_RUN_FLAG
91 changes: 0 additions & 91 deletions .github/workflows/build_test_publish_release.yml

This file was deleted.

Loading

0 comments on commit 1591ee9

Please sign in to comment.