-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(WIP): use artifacts to aggregate build outputs
- Loading branch information
1 parent
1d650d7
commit f9fd53b
Showing
2 changed files
with
179 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
.github/workflows/job-99-generic-attach_artifact_to_release.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
name: job-99-generic-attach_artifact_to_release | ||
|
||
# Consuming Projects Must Implement: | ||
# - ./.github/scripts/step-setup-environment.sh | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
ARTIFACT_NAME_PATTERN: | ||
default: "" | ||
description: "Optional, a glob pattern to identify artifacts that should be downloaded prior to upload." | ||
required: false | ||
type: string | ||
ERROR_COMMAND: | ||
default: "" | ||
description: "Optional, a command to run if the workflow fails." | ||
required: false | ||
type: string | ||
RELEASE_CONTEXT: | ||
description: "A JSON encoded release context object from a newly generated release." | ||
required: true | ||
type: string | ||
REMOTE_SCRIPT_ATTACH_TO_RELEASE: | ||
default: "ci/github/scripts/job-99-attach-to-release.js" | ||
description: "Optional, allows you to specify a script to attach files to a GitHub release." | ||
required: false | ||
type: string | ||
TESTING_MODE: | ||
default: false | ||
description: "Optional, allows you to test a workflow failure." | ||
required: false | ||
type: boolean | ||
UPLOAD_FOLDERS: | ||
description: "A newline delimited list of folders who's content will be attached to the release." | ||
required: true | ||
type: string | ||
WORKFLOW_NAME: | ||
default: "" | ||
description: "Identifies this workflow in notifications." | ||
required: false | ||
type: string | ||
VERBOSE_NOTIFICATIONS: | ||
default: false | ||
description: "Optional, allows you to enable verbose notifications." | ||
required: false | ||
type: boolean | ||
secrets: | ||
SLACK_WEBHOOK: | ||
description: "Optional, enables Slack notifications." | ||
required: false | ||
|
||
jobs: | ||
|
||
attach_to_release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Attach to Release -- Repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Attach to Release -- Install Toolbox | ||
uses: ./.github/actions/action-00-toolbox | ||
|
||
- name: Attach to Release -- Setup Environment | ||
env: | ||
WORKFLOW_NAME: ${{ inputs.WORKFLOW_NAME }} | ||
run: | | ||
bash "./.github/scripts/step-setup-environment.sh" | ||
shell: bash | ||
|
||
- name: Attach to Release -- Download Artifacts | ||
if: inputs.ARTIFACT_NAME_PATTERN != '' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: . | ||
pattern: ${{ inputs.ARTIFACT_NAME_PATTERN }} | ||
merge-multiple: true | ||
|
||
- name: Attach to Release -- Unpack Artifacts | ||
if: inputs.ARTIFACT_NAME_PATTERN != '' | ||
run: | | ||
for FILE in ./*.tar.gz; do tar xvzf "${FILE}"; done | ||
- name: Attach to Release -- Attach Files | ||
env: | ||
RELEASE_CONTEXT: ${{ inputs.RELEASE_CONTEXT }} | ||
UPLOAD_FOLDERS: ${{ inputs.UPLOAD_FOLDERS }} | ||
if: inputs.TESTING_MODE == false | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const fs = require('fs'); | ||
const script = require('./.cicd-tools/boxes/active/${{ inputs.REMOTE_SCRIPT_ATTACH_TO_RELEASE }}'); | ||
const folders = process.env.UPLOAD_FOLDERS; | ||
const release = JSON.parse(process.env.RELEASE_CONTEXT); | ||
await script({ context, core, fs, folders, github, release }) | ||
- name: Attach to Release -- Report Job Status on Success | ||
if: inputs.VERBOSE_NOTIFICATIONS == true | ||
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification | ||
with: | ||
NOTIFICATION_MESSAGE: | | ||
The build artifacts have been attached to the release! | ||
https://github.com/${{ env.PROJECT_OWNER }}/${{ env.PROJECT_NAME }}/releases | ||
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | ||
|
||
- name: Attach to Release -- Report Job Status on Failure | ||
if: failure() || inputs.TESTING_MODE == true | ||
uses: ./.cicd-tools/boxes/active/ci/github/actions/action-00-generic-notification | ||
with: | ||
NOTIFICATION_EMOJI: ":x:" | ||
NOTIFICATION_MESSAGE: "An error occurred while attaching build artifacts to the release!" | ||
NOTIFICATION_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | ||
TESTING_MODE: ${{ inputs.TESTING_MODE }} | ||
|
||
- name: Attach to Release -- Error Command | ||
if: failure() && inputs.ERROR_COMMAND != '' | ||
run: | | ||
${{ inputs.ERROR_COMMAND }} | ||
shell: bash |