mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 08:36:11 +02:00
feat: Update CI workflows to trigger on successful completion of previous CI runs
This commit is contained in:
@@ -33,6 +33,8 @@ jobs:
|
||||
|
||||
build-and-test:
|
||||
name: Build & Test
|
||||
# Run the cheap, fast checks first; only spend build/test compute if they pass.
|
||||
needs: [format-check, lint-markdown]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
name: Docker
|
||||
|
||||
# Runs only after the CI workflow completes, so an image is never pushed for a commit
|
||||
# whose formatting, lint, build, or tests failed.
|
||||
on:
|
||||
push:
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
types: [completed]
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -15,23 +19,29 @@ env:
|
||||
jobs:
|
||||
docker:
|
||||
name: Build & Push Docker Image
|
||||
# Proceed only for a successful CI run on a master push, or a manual dispatch.
|
||||
if: >-
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.event == 'push' &&
|
||||
github.event.workflow_run.head_branch == 'master')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# The exact commit CI tested (workflow_run), or the current tip (manual dispatch).
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
- name: Check for src/ changes
|
||||
id: changes
|
||||
env:
|
||||
BEFORE: ${{ github.event.before }}
|
||||
run: |
|
||||
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
|
||||
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
||||
if git rev-parse HEAD~1 >/dev/null 2>&1; then
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD -- 'src/' | wc -l)
|
||||
else
|
||||
CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
|
||||
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
||||
CHANGED=1
|
||||
fi
|
||||
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Read version
|
||||
if: steps.changes.outputs.src_changed == 'true'
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
name: Release
|
||||
|
||||
# Runs only after the CI workflow completes, so a release is never published on a commit
|
||||
# whose formatting, lint, build, or tests failed.
|
||||
on:
|
||||
push:
|
||||
workflow_run:
|
||||
workflows: ["CI"]
|
||||
types: [completed]
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
@@ -11,6 +15,12 @@ permissions:
|
||||
jobs:
|
||||
release:
|
||||
name: Create Release
|
||||
# Proceed only for a successful CI run on a master push, or a manual dispatch.
|
||||
if: >-
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event.workflow_run.conclusion == 'success' &&
|
||||
github.event.workflow_run.event == 'push' &&
|
||||
github.event.workflow_run.head_branch == 'master')
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_release: ${{ steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false' }}
|
||||
@@ -21,18 +31,18 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# The exact commit CI tested (workflow_run), or the current tip (manual dispatch).
|
||||
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
- name: Check for src/ changes
|
||||
id: changes
|
||||
env:
|
||||
BEFORE: ${{ github.event.before }}
|
||||
run: |
|
||||
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
|
||||
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
||||
if git rev-parse HEAD~1 >/dev/null 2>&1; then
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD -- 'src/' | wc -l)
|
||||
else
|
||||
CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
|
||||
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
||||
CHANGED=1
|
||||
fi
|
||||
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Read version
|
||||
id: version
|
||||
|
||||
Reference in New Issue
Block a user