Starter Workflow #13
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: Starter Workflow | |
on: | |
# Webhook events | |
push: | |
branches: | |
- 'release/*' | |
paths-ignore: | |
- '.github/workflows' | |
issues: | |
types: [opened, reopened] | |
# Scheduled events | |
schedule: | |
# - cron: '*/15 * * * *' | |
# - cron: '0 9-17 * * *' | |
- cron: '11 11 * * 5' | |
# Manual events | |
workflow_dispatch: | |
inputs: | |
homedrive: | |
description: 'The home drive on the machine' | |
required: true | |
default: '/home' | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
run_matrix: | |
description: 'Run the matrix jobs' | |
required: true | |
type: boolean | |
environment: | |
description: 'Environment to run tests against' | |
type: environment | |
required: true | |
# Trigger using the API | |
repository_dispatch: | |
types: [customEvent] | |
# Call for example using GitHub CLI: | |
# $ gh api -X POST -H "Accept: application/vnd.github.v3+json" \ | |
# /repos/ahmedbham/AccelerateDevOps/dispatches \ | |
# -f event_type=customEvent | |
env: | |
MY_ENV: A value availbale as environment variable | |
permissions: | |
contents: read | |
issues: write | |
jobs: | |
job_1: | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "🎉 The job was triggered by a ${{ github['event_name'] }} event." | |
- run: echo "🏠 drive is `${{ github.event.inputs.homedrive }}`." | |
- run: echo "🎯 environment is `${{ github.event.inputs.environment }}`." | |
- run: echo "📖 log level is `${{ github.event.inputs.logLevel }}`." | |
- run: echo "➿ Run the matrix? `${{ github.event.inputs.run_matrix }}`." | |
- name: Get OS information | |
run: | | |
import platform | |
print(platform.platform()) | |
shell: python | |
- uses: actions/checkout@v4 | |
#- uses: actions/[email protected] | |
#- uses: actions/checkout@v4 | |
#- uses: actions/checkout@main | |
- name: Run a docker containers as an action | |
uses: docker://alpine:3.8 | |
- uses: docker://ghcr.io/wulfland/container-demo:latest | |
- name: Display documentation | |
run: tree | |
working-directory: docs | |
job_2: | |
runs-on: ubuntu-latest | |
needs: job_1 | |
steps: | |
- run: echo "Status ${{ job.status }}" | |
job_3: | |
runs-on: ubuntu-latest | |
needs: job_1 | |
steps: | |
- run: echo "Services ${{ job.services }}" | |
job_4: | |
runs-on: ubuntu-latest | |
needs: [job_2, job_3] | |
steps: | |
- run: echo "Status ${{ job.status }}" | |
matrix_job: | |
name: Matrix | |
runs-on: ${{ matrix.runner }} | |
if: github.event.inputs.run_matrix == 'true' | |
strategy: | |
matrix: | |
runner: [ubuntu-18.04, ubuntu-20.04] | |
node: [10,12] | |
fail-fast: true | |
max-parallel: 4 | |
steps: | |
- run: echo "${{ matrix.runner }}" | |
- run: echo "${{ matrix.node }}" | |
context_job: | |
runs-on: ubuntu-latest | |
name: Context | |
steps: | |
- name: Dump GitHub context | |
run: echo '${{ toJSON(github) }}' | |
- name: Dump job context | |
run: echo '${{ toJSON(job) }}' | |
- name: Dump runner context | |
run: echo '${{ toJSON(runner) }}' | |
- name: Dump env context | |
run: echo '${{ toJSON(env) }}' | |
expression_job: | |
runs-on: ubuntu-latest | |
name: Expressions | |
if: ${{ github.ref == 'refs/heads/main' && github.event.inputs.logLevel == 'debug' }} | |
steps: | |
- run: echo "Only run if triggered by main branch..." | |
if: contains(github.ref, 'main') | |
- run: | | |
echo "Fail depending on parameter" | |
return 1 | |
if: github.event.inputs.run_matrix == 'true' | |
- run: echo "Run always" | |
if: always() | |
- run: echo "Run only on success" | |
if: success() | |
- run: echo "Run only on failure" | |
if: failure() | |
workflow_commands: | |
runs-on: ubuntu-latest | |
name: Workflow Commands | |
steps: | |
- name: Set time | |
run: echo 'my_time=$(date)' >> $GITHUB_OUTPUT | |
id: set-time | |
- name: Output time | |
run: echo "It was ${{ steps.set-time.outputs.my_time }} in the previous step." | |
- name: Writing to the workflow log | |
run: | | |
echo "Writing to the workflow log" | |
echo "::group::Writing to the log" | |
echo "::notice file=starter.yml,line=169,col=19,endColumn=22::Writing a notice" | |
echo "::warning file=starter.yml,line=171,col=19,endColumn=22::Writing a warning" | |
echo "::endgroup::" | |
label_issues: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'issues' | |
steps: | |
- uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 | |
with: | |
add-labels: documentation | |
repo-token: ${{ secrets.GITHUB_TOKEN }} |