Skip to content

Commit

Permalink
ci: create new on pull request update ci using reusable workflows (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdash99 authored Aug 24, 2023
1 parent 01441a8 commit d2b690c
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
104 changes: 104 additions & 0 deletions .github/workflows/on-pr-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: PR Update

on:
pull_request:
types:
- opened
- synchronize

jobs:

slack:
# Open a new PR thread on Slack for this CI run.
uses: SwanseaUniversityMedical/workflows/.github/workflows/[email protected]
with:
slack-channel: ${{ vars.SLACK_CHANNEL }}
secrets:
slack-token: ${{ secrets.SLACK_TOKEN }}

changes:
# Detect which files have been changed on this PR's full history
needs: slack
uses: SwanseaUniversityMedical/workflows/.github/workflows/[email protected]
with:
slack-channel: ${{ vars.SLACK_CHANNEL }}
slack-thread: ${{ needs.slack.outputs.thread }}
github-app-id: ${{ vars.APP_ID }}
filters: |
container:
- './.github/workflows/on-pr-update.yaml'
- 'containers/hive/**'
chart:
- './.github/workflows/on-pr-update.yaml'
- 'charts/**'
secrets:
slack-token: ${{ secrets.SLACK_TOKEN }}
github-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}

build-container:
# Build the container and push it as :pr-42 and :pr-42-fe45b3h
needs:
- slack
- changes
if: fromJSON(needs.changes.outputs.changes).container == 'true'
uses: SwanseaUniversityMedical/workflows/.github/workflows/[email protected]
with:
job-name: hive-container
container-registry: ${{ vars.HARBOR_REGISTRY }}
container-registry-user: ${{ vars.HARBOR_USER }}
container-registry-project: ${{ vars.HARBOR_PROJECT }}
container-registry-repo: ${{ vars.HARBOR_REPO }}
github-app-id: ${{ vars.APP_ID }}
slack-channel: ${{ vars.SLACK_CHANNEL }}
slack-thread: ${{ needs.slack.outputs.thread }}
build-command: |
docker build -t $IMAGE -f containers/hive/Dockerfile .
test-command: |
echo '0'
secrets:
container-registry-token: ${{ secrets.HARBOR_TOKEN }}
github-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
slack-token: ${{ secrets.SLACK_TOKEN }}


build-pr-chart:
# Build the chart and push it as :pr-42 and :pr-42-fe45b3h
needs:
- slack
- changes
if: fromJSON(needs.changes.outputs.changes).chart == 'true'
uses: SwanseaUniversityMedical/workflows/.github/workflows/[email protected]
with:
job-name: hive-chart
chart: charts/**
chart-registry: ${{ vars.HARBOR_REGISTRY }}
chart-registry-user: ${{ vars.HARBOR_USER }}
chart-registry-project: ${{ vars.HARBOR_PROJECT }}
chart-registry-repo: ${{ vars.HARBOR_REPO }}
github-app-id: ${{ vars.APP_ID }}
slack-channel: ${{ vars.SLACK_CHANNEL }}
slack-thread: ${{ needs.slack.outputs.thread }}
test-command: |
helm template $CHART --values charts/hive/values.yaml
secrets:
chart-registry-token: ${{ secrets.HARBOR_TOKEN }}
github-app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
slack-token: ${{ secrets.SLACK_TOKEN }}

slack-update:
# Update the original Slack message with the final workflow status
# WARNING! ALL UPSTREAM JOBS MUST BE DECLARED HERE TO REPORT FAILURES CORRECTLY!
needs:
- slack
- changes
- build-container
- build-pr-chart
uses: SwanseaUniversityMedical/workflows/.github/workflows/[email protected]
if: always()
with:
slack-channel: ${{ vars.SLACK_CHANNEL }}
slack-thread: ${{ needs.slack.outputs.thread }}
status: ${{ contains(join(needs.*.result, ','), 'failure') && ':no_entry:' || ':white_check_mark:' }}
secrets:
slack-token: ${{ secrets.SLACK_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'containers/**'
- 'charts/**'
branches:
- '**'
- 'main'

env:
HARBOR_REGISTRY: ${{ vars.HARBOR_REGISTRY }}
Expand Down

0 comments on commit d2b690c

Please sign in to comment.