Last active
February 4, 2024 15:52
-
-
Save brentlaster/5372bd941e3186a39bd2685c748c1447 to your computer and use it in GitHub Desktop.
Sample files for @getskillsnow CICD in 3 weeks course
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
name: 'Test Action' | |
description: 'Runs a simple execution to validate compiled built deliverable' | |
author: 'attendee' | |
inputs: | |
artifact-version: # semantic version of the artifact from build | |
description: 'built version of artifact' | |
required: true | |
default: '1.0.0' | |
arguments-to-print: # rest of arguments to echo out | |
description: 'arguments to print out' | |
runs: | |
using: "composite" | |
steps: | |
- name: Download candidate artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: greetings-jar | |
- id: test-run | |
env: | |
ARGS: ${{ inputs.arguments-to-print }} | |
run: | | |
chmod +x ${{ github.action_path }}/test-script.sh | |
${{ github.action_path }}/test-script.sh ${{ inputs.artifact-version }} "$ARGS" | |
shell: bash |
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
# This is a reusable workflow for creating an issue | |
name: create-failure-issue | |
# Controls when the workflow will run | |
on: | |
# Allows you to run this workflow from another workflow | |
workflow_call: | |
inputs: | |
title: | |
required: true | |
type: string | |
body: | |
required: true | |
type: string | |
# Allows you to call this manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
title: | |
description: 'Issue title' | |
required: true | |
body: | |
description: 'Issue body' | |
required: true | |
jobs: | |
create_issue_on_failure: | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
steps: | |
- name: Create issue using REST API | |
run: | | |
curl --request POST \ | |
--url https://api.github.com/repos/${{ github.repository }}/issues \ | |
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
--header 'content-type: application/json' \ | |
--data '{ | |
"title": "Failure: ${{ inputs.title }}", | |
"body": "Details: ${{ inputs.body }}" | |
}' \ | |
--fail |
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
create-issue-on-failure: | |
needs: test-run | |
permissions: | |
issues: write | |
if: always() && failure() | |
uses: ./.github/workflows/create-failure-issue.yml | |
with: | |
title: "Automated workflow failure issue for commit ${{ github.sha }}" | |
body: "This issue was automatically created by the GitHub Action workflow ** ${{ github.workflow }} **" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment