Skip to content

Commit 3396b6a

Browse files
Merge pull request #150 from isaqb-org/outsource_workflows
Outsource workflows
2 parents 3d944c1 + 3a2a869 commit 3396b6a

File tree

4 files changed

+13
-236
lines changed

4 files changed

+13
-236
lines changed

.github/workflows/build_main.yml

Lines changed: 4 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,8 @@ on:
1010
tags:
1111
- "[2-9][0-9][0-9][0-9].[0-9]+-rev[0-9]+"
1212

13-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1413
jobs:
15-
# This workflow contains a single job called "build"
16-
build:
17-
# The type of runner that the job will run on
18-
runs-on: ubuntu-latest
19-
20-
# Steps represent a sequence of tasks that will be executed as part of the job
21-
steps:
22-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
23-
- name: Checkout Source
24-
uses: actions/checkout@v3
25-
with:
26-
submodules: recursive
27-
- name: Verify Gradle Wrapper
28-
uses: gradle/wrapper-validation-action@v1
29-
- name: Set up JDK 17
30-
uses: actions/setup-java@v3
31-
with:
32-
distribution: 'temurin'
33-
java-version: 17
34-
35-
# If we're building a release, we need to set the variable RELEASE_VERSION
36-
- name: Set Environment Variables for Release Version
37-
if: startsWith(github.ref, 'refs/tags/')
38-
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
39-
40-
- name: Execute Gradle Build
41-
uses: gradle/gradle-build-action@v2
42-
env:
43-
CI: true
44-
with:
45-
gradle-version: wrapper
46-
arguments: buildDocs
47-
48-
# release and deploy only if we're building a release
49-
- name: Prepare Deployment
50-
if: startsWith(github.ref, 'refs/tags/')
51-
run: |
52-
rm -rf ./build/tmp
53-
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
54-
zip -r release.zip ./build
55-
mkdir release_dir
56-
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
57-
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
58-
- name: Create New Release
59-
if: startsWith(github.ref, 'refs/tags/')
60-
id: create-release
61-
uses: ncipollo/release-action@v1
62-
env:
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
64-
with:
65-
tag: ${{ env.RELEASE_VERSION }}
66-
name: Release ${{ env.RELEASE_VERSION }}
67-
draft: false
68-
prerelease: false
69-
bodyFile: "CHANGELOG.md"
70-
artifacts: "license-copyright/LICENSE.adoc,release_dir/*.pdf,release_dir/*.zip"
71-
token: ${{ secrets.GITHUB_TOKEN }}
72-
- name: Deploy
73-
if: startsWith(github.ref, 'refs/tags/')
74-
uses: peaceiris/actions-gh-pages@v3
75-
with:
76-
github_token: ${{ secrets.GITHUB_TOKEN }}
77-
publish_dir: ./build
78-
user_name: 'github-actions[bot]'
79-
user_email: 'github-actions[bot]@users.noreply.github.com'
80-
commit_message: Publish Release ${{ env.RELEASE_VERSION }}
14+
call_workflow_build:
15+
uses: isaqb-org/github-workflows/.github/workflows/build_main.yml@main
16+
with:
17+
release_version: env.RELEASE_VERSION

.github/workflows/build_pr.yml

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,7 @@ name: CI – Pull Requests
77
on:
88
pull_request:
99
branches: [ main ]
10-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11-
jobs:
12-
# This workflow contains a single job called "build"
13-
build:
14-
# The type of runner that the job will run on
15-
runs-on: ubuntu-latest
1610

17-
# Steps represent a sequence of tasks that will be executed as part of the job
18-
steps:
19-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
20-
- name: checkout source
21-
uses: actions/checkout@v3
22-
with:
23-
submodules: recursive
24-
- name: Verify Gradle Wrapper
25-
uses: gradle/wrapper-validation-action@v1
26-
- name: Set up JDK 17
27-
uses: actions/setup-java@v3
28-
with:
29-
distribution: 'temurin'
30-
java-version: 17
31-
- name: Execute Gradle Build
32-
uses: gradle/gradle-build-action@v2
33-
with:
34-
gradle-version: wrapper
35-
arguments: buildDocs
36-
- name: Upload Build Artifacts
37-
uses: actions/upload-artifact@v3
38-
with:
39-
name: curriculum files (PDF and HTML)
40-
path: |
41-
build/*.pdf
42-
build/*.html
43-
retention-days: 10
11+
jobs:
12+
call_workflow_build_pr:
13+
uses: isaqb-org/github-workflows/.github/workflows/build_pr.yml@main

.github/workflows/build_releasecandidate.yml

Lines changed: 4 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,77 +9,8 @@ on:
99
tags:
1010
- "[2-9][0-9][0-9][0-9].[0-9]+-RC[0-9]+"
1111

12-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1312
jobs:
14-
# This workflow contains a single job called "build"
15-
build:
16-
# The type of runner that the job will run on
17-
runs-on: ubuntu-latest
18-
19-
# Steps represent a sequence of tasks that will be executed as part of the job
20-
steps:
21-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22-
- name: Checkout Source
23-
uses: actions/checkout@v3
24-
with:
25-
submodules: recursive
26-
- name: Update index.adoc
27-
run: |
28-
rm docs/index.adoc
29-
mv docs/index_rc.adoc docs/index.adoc
30-
- name: Verify Gradle Wrapper
31-
uses: gradle/wrapper-validation-action@v1
32-
- name: Set up JDK 17
33-
uses: actions/setup-java@v3
34-
with:
35-
distribution: 'temurin'
36-
java-version: 17
37-
38-
# If we're building a release, we need to set the variable RELEASE_VERSION
39-
- name: Set Environment Variables for Release Version
40-
if: startsWith(github.ref, 'refs/tags/')
41-
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
42-
43-
- name: Execute Gradle Build
44-
uses: gradle/gradle-build-action@v2
45-
env:
46-
CI: true
47-
with:
48-
gradle-version: wrapper
49-
arguments: buildDocs
50-
51-
# do the following two things only for a release!
52-
- name: Prepare Deployment
53-
if: startsWith(github.ref, 'refs/tags/')
54-
run: |
55-
rm -rf ./build/tmp
56-
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
57-
zip -r release.zip ./build
58-
mkdir release_dir
59-
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
60-
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
61-
- name: Create New Release Candidate
62-
if: startsWith(github.ref, 'refs/tags/')
63-
id: create-release-candidate
64-
uses: ncipollo/release-action@v1
65-
env:
66-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
67-
with:
68-
tag: ${{ env.RELEASE_VERSION }}
69-
name: Release Candidate ${{ env.RELEASE_VERSION }}
70-
draft: false
71-
prerelease: true
72-
bodyFile: "CHANGELOG.md"
73-
artifacts: "license-copyright/LICENSE.adoc,release_dir/*.pdf,release_dir/*.zip"
74-
token: ${{ secrets.GITHUB_TOKEN }}
75-
- name: Deploy Release Candidate to GitHub Pages
76-
if: startsWith(github.ref, 'refs/tags/')
77-
uses: peaceiris/actions-gh-pages@v3
78-
with:
79-
github_token: ${{ secrets.GITHUB_TOKEN }}
80-
publish_dir: ./build
81-
destination_dir: release-candidate
82-
keep_files: true
83-
user_name: 'github-actions[bot]'
84-
user_email: 'github-actions[bot]@users.noreply.github.com'
85-
commit_message: Publish Release Candidate ${{ env.RELEASE_VERSION }}
13+
call_workflow_build_pr:
14+
uses: isaqb-org/github-workflows/.github/workflows/build_releasecandidate.yml@main
15+
with:
16+
release_version: env.RELEASE_VERSION

.github/workflows/update_pr_with_comment.yml

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -6,66 +6,5 @@ on:
66
workflows: [CI – Pull Requests]
77

88
jobs:
9-
comment:
10-
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{github.event_name == 'pull_request' }}
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: Get Artifact and Pull request info
14-
env:
15-
GITHUB_TOKEN: ${{ github.token }}
16-
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
17-
OWNER: ${{ github.repository_owner }}
18-
REPO: ${{ github.event.repository.name }}
19-
run: |
20-
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
21-
echo "Previous Job ID: $PREVIOUS_JOB_ID"
22-
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"
23-
24-
SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
25-
echo "Previous Suite ID: $SUITE_ID"
26-
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"
27-
28-
ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
29-
--jq ".artifacts.[] |
30-
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
31-
select(.expired==false) |
32-
.id")
33-
34-
echo "Artifact ID: $ARTIFACT_ID"
35-
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"
36-
37-
PR_NUMBER=$(jq -r '.pull_requests[0].number' \
38-
<<< "$WORKFLOW_RUN_EVENT_OBJ")
39-
40-
echo "Pull request Number: $PR_NUMBER"
41-
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"
42-
43-
HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
44-
<<< "$WORKFLOW_RUN_EVENT_OBJ")
45-
46-
echo "Head SHA: $HEAD_SHA"
47-
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
48-
- name: Find Comment
49-
uses: peter-evans/find-comment@v2
50-
id: find-comment
51-
with:
52-
issue-number: ${{ env.PR_NUMBER }}
53-
comment-author: 'github-actions[bot]'
54-
- name: Update Comment
55-
env:
56-
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
57-
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
58-
HEAD_SHA: "${{ env.HEAD_SHA }}"
59-
uses: peter-evans/create-or-update-comment@v3
60-
with:
61-
issue-number: ${{ env.PR_NUMBER }}
62-
comment-id: ${{ steps.find-comment.outputs.comment-id }}
63-
edit-mode: replace
64-
body: |-
65-
Build Successful! You can find a link to the downloadable artifacts below.
66-
67-
| Name | Link |
68-
| -------- | ----------------------- |
69-
| Commit | ${{ env.HEAD_SHA }} |
70-
| Logs | ${{ env.JOB_PATH }} |
71-
| Download | ${{ env.ARTIFACT_URL }} |
9+
call_workflow_build:
10+
uses: isaqb-org/github-workflows/.github/workflows/update_pr_with_comment.yml@main

0 commit comments

Comments
 (0)