Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outsource workflows #150

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 4 additions & 67 deletions .github/workflows/build_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,8 @@ on:
tags:
- "[2-9][0-9][0-9][0-9].[0-9]+-rev[0-9]+"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Source
uses: actions/checkout@v3
with:
submodules: recursive
- name: Verify Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

# If we're building a release, we need to set the variable RELEASE_VERSION
- name: Set Environment Variables for Release Version
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: Execute Gradle Build
uses: gradle/gradle-build-action@v2
env:
CI: true
with:
gradle-version: wrapper
arguments: buildDocs

# release and deploy only if we're building a release
- name: Prepare Deployment
if: startsWith(github.ref, 'refs/tags/')
run: |
rm -rf ./build/tmp
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
zip -r release.zip ./build
mkdir release_dir
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
- name: Create New Release
if: startsWith(github.ref, 'refs/tags/')
id: create-release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag: ${{ env.RELEASE_VERSION }}
name: Release ${{ env.RELEASE_VERSION }}
draft: false
prerelease: false
bodyFile: "CHANGELOG.md"
artifacts: "license-copyright/LICENSE.adoc,release_dir/*.pdf,release_dir/*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy
if: startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: Publish Release ${{ env.RELEASE_VERSION }}
call_workflow_build:
uses: isaqb-org/github-workflows/.github/workflows/build_main.yml@main
with:
release_version: env.RELEASE_VERSION
36 changes: 3 additions & 33 deletions .github/workflows/build_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,7 @@ name: CI – Pull Requests
on:
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout source
uses: actions/checkout@v3
with:
submodules: recursive
- name: Verify Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Execute Gradle Build
uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
arguments: buildDocs
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: curriculum files (PDF and HTML)
path: |
build/*.pdf
build/*.html
retention-days: 10
jobs:
call_workflow_build_pr:
uses: isaqb-org/github-workflows/.github/workflows/build_pr.yml@main
77 changes: 4 additions & 73 deletions .github/workflows/build_releasecandidate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,77 +9,8 @@ on:
tags:
- "[2-9][0-9][0-9][0-9].[0-9]+-RC[0-9]+"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout Source
uses: actions/checkout@v3
with:
submodules: recursive
- name: Update index.adoc
run: |
rm docs/index.adoc
mv docs/index_rc.adoc docs/index.adoc
- name: Verify Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

# If we're building a release, we need to set the variable RELEASE_VERSION
- name: Set Environment Variables for Release Version
if: startsWith(github.ref, 'refs/tags/')
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV

- name: Execute Gradle Build
uses: gradle/gradle-build-action@v2
env:
CI: true
with:
gradle-version: wrapper
arguments: buildDocs

# do the following two things only for a release!
- name: Prepare Deployment
if: startsWith(github.ref, 'refs/tags/')
run: |
rm -rf ./build/tmp
cp ./docs-ext/curriculum-*.pdf ./build 2>/dev/null || :
zip -r release.zip ./build
mkdir release_dir
cp ./build/curriculum-*.pdf ./release_dir 2>/dev/null || :
mv release.zip ./release_dir/release-${{ env.RELEASE_VERSION }}.zip
- name: Create New Release Candidate
if: startsWith(github.ref, 'refs/tags/')
id: create-release-candidate
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag: ${{ env.RELEASE_VERSION }}
name: Release Candidate ${{ env.RELEASE_VERSION }}
draft: false
prerelease: true
bodyFile: "CHANGELOG.md"
artifacts: "license-copyright/LICENSE.adoc,release_dir/*.pdf,release_dir/*.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy Release Candidate to GitHub Pages
if: startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
destination_dir: release-candidate
keep_files: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: Publish Release Candidate ${{ env.RELEASE_VERSION }}
call_workflow_build_pr:
uses: isaqb-org/github-workflows/.github/workflows/build_releasecandidate.yml@main
with:
release_version: env.RELEASE_VERSION
65 changes: 2 additions & 63 deletions .github/workflows/update_pr_with_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,66 +6,5 @@ on:
workflows: [CI – Pull Requests]

jobs:
comment:
if: ${{ github.event.workflow_run.conclusion == 'success' }} && ${{github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Get Artifact and Pull request info
env:
GITHUB_TOKEN: ${{ github.token }}
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
run: |
PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Job ID: $PREVIOUS_JOB_ID"
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"

SUITE_ID=$(jq -r '.check_suite_id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Suite ID: $SUITE_ID"
echo "SUITE_ID=$SUITE_ID" >> "$GITHUB_ENV"

ARTIFACT_ID=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.id")

echo "Artifact ID: $ARTIFACT_ID"
echo "ARTIFACT_ID=$ARTIFACT_ID" >> "$GITHUB_ENV"

PR_NUMBER=$(jq -r '.pull_requests[0].number' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "Pull request Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"

HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "Head SHA: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ env.PR_NUMBER }}
comment-author: 'github-actions[bot]'
- name: Update Comment
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ env.PREVIOUS_JOB_ID }}"
ARTIFACT_URL: "${{ github.server_url }}/${{ github.repository }}/suites/${{ env.SUITE_ID }}/artifacts/${{ env.ARTIFACT_ID }}"
HEAD_SHA: "${{ env.HEAD_SHA }}"
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ env.PR_NUMBER }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |-
Build Successful! You can find a link to the downloadable artifacts below.

| Name | Link |
| -------- | ----------------------- |
| Commit | ${{ env.HEAD_SHA }} |
| Logs | ${{ env.JOB_PATH }} |
| Download | ${{ env.ARTIFACT_URL }} |
call_workflow_build:
uses: isaqb-org/github-workflows/.github/workflows/update_pr_with_comment.yml@main
Loading