Skip to content

Commit

Permalink
ci: add new build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseylin committed Jul 26, 2023
1 parent 6b19a8b commit 81aef04
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
workflow_dispatch:
workflow_call:
inputs:
is_pull_request:
push-images:
required: true
type: boolean
sem_ver:
sem-ver:
required: false
type: string
secrets:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
context: "./services/base/JupyterLab"
runs-on: ubuntu-latest
env:
SEMVER: ${{ inputs.is_propagated_pull_request && inputs.sem_ver || ''}}
SEMVER: ${{ inputs.is_propagated_pull_request && inputs.sem-ver || ''}}
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -63,7 +63,7 @@ jobs:
type=semver,pattern={{major}}
type=sha,prefix=sha-
- name: Login to Gitlab registry
if: github.event_name != 'pull_request' && inputs.is_propagated_pull_request == false
if: inputs.push_images
uses: docker/login-action@v2
with:
registry: registry.gitlab.inria.fr/cromac/automateddiscoverytool
Expand All @@ -73,6 +73,6 @@ jobs:
uses: docker/build-push-action@v4
with:
context: ${{ matrix.context }}
push: ${{ github.event_name != 'pull_request' && inputs.is_propagated_pull_request == false }}
push: ${{ inputs.push_images }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow reacts to pull requests.
#
# If a pull request from the
# release-please workflow is detected, documentation and image building is done
# in the PR as a CI test.
#
# If a pull request from the release-please workflow is merged, the release's
# semantic version is retrieved and the previous jobs are run, with the images
# being pushed.

on:
pull_request:
jobs:
if-merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Retrieve semantic version from PR
id: retrieve-semver
run: |
if [[ ${{ github.event.pull_request.title }} =~ ^chore.*:\ release.*\ ([0-9\.]+)$ ]]; then
echo "Got PR: ${{ github.event.pull_request.title }}"
echo "semver=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT
fi
outputs:
sem-ver: ${{ steps.retrieve-semver.outputs.semver }}
build-docs:
if: "${{ contains(github.event.pull_request.labels.*.name, autorelease: pending }}"
uses: ./.github/workflows/build-docs.yml
build-images:
if: "${{ contains(github.event.pull_request.labels.*.name, autorelease: pending }}"
uses: ./.github/workflows/build-images.yml
secrets: inherit
with:
push-images: ${{ github.event.pull_request.merged }}
sem-ver: ${{ jobs.if-merged.outputs.sem-ver }}
14 changes: 1 addition & 13 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ jobs:
- id: release-please
uses: google-github-actions/release-please-action@v3
with:
pull-request-title-pattern: "chore${scope}: release${component} ${version}"
release-type: simple
default-branch: dev
outputs:
releases_created: ${{ steps.release-please.releases_created }}
sem_ver: ${{ steps.release-pr.major }}.${{ steps.release-pr.minor }}.${{ steps.release-pr.patch }}
build-docs:
needs: release-pr
uses: ./.github/workflows/build-docs.yml
build-images:
needs: release-pr
uses: ./.github/workflows/build-images.yml
with:
is_pull_request: ${{ needs.release-pr.outputs.releases_created }}
sem_ver: ${{ needs.release-pr.outputs.sem_ver }}
secrets: inherit

0 comments on commit 81aef04

Please sign in to comment.