Alliedium/awesome-github-actions
13 workflows · maturity 17% · 2 patterns · GitHub ↗
Practices
✓ Matrix○ Permissions○ Security scan○ AI review○ Cache○ Concurrency○ Reusable workflows
Detected patterns
Security dimensions
Workflows (13)
01-hello-world .github/workflows/01-hello-world.yml
View raw YAML
name: hello-world-example
on:
push:
paths:
- '.github/workflows/01-hello-world.yml'
jobs:
say-hello:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./01-hello-world
run: pwd
- name: Say Hello
run: echo "Hello world!"
- name: Do stuff
run: |
echo "Step 1..."
echo "Step 2..."
echo "Step 3..."
echo "Step 4..."
- name: Say Goodbye
run: echo "Goodbye!"02-event-triggers .github/workflows/02-event-triggers.yml
View raw YAML
name: event-triggers-example
on:
push:
branches:
- '02-develop'
- '02-foo/*'
- '02-foo/**'
- '!02-foo/*/456'
tags:
- '*'
paths:
- '.github/workflows/02-event-triggers.yml'
pull_request:
branches:
- '02-develop'
paths:
- '.github/workflows/02-event-triggers.yml'
schedule:
- cron: '*/45 9-12 * * 1,4'
jobs:
say-hello:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./02-event-triggers
run: pwd
- name: Event
run: echo "Triggered by $GITHUB_EVENT_NAME"
- name: Say Hello
run: echo "Hello world!"03-actions .github/workflows/03-actions.yml
View raw YAML
name: actions-example
on:
push:
paths:
- '03-actions/**.js'
- '.github/workflows/03-actions.yml'
jobs:
use-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '15.8.0'
-
name: Install repo dependencies
working-directory: ./03-actions
run: npm install
-
name: Run script from repo
working-directory: ./03-actions
run: node helloWorld.js04-environment-variables .github/workflows/04-environment-variables.yml
View raw YAML
name: env-vars-example
on:
push:
paths:
- '.github/workflows/04-environment-variables.yml'
env:
VENI: 'I came'
jobs:
use-env-vars:
runs-on: ubuntu-latest
env:
VIDI: 'I saw'
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./04-environment-variables
run: pwd
- name: Show me the vars
run: echo "$VENI, $VIDI, $VICI"
env:
VICI: 'I conquered'
- name: Create env var
run: echo "foo=bar" >> $GITHUB_ENV
- name: Useful default vars
run: |
echo "Workflow name: $GITHUB_WORKFLOW"
echo "Workspace: $GITHUB_WORKSPACE"
echo "Event: $GITHUB_EVENT_NAME"
echo "SHA: $GITHUB_SHA"
echo "Ref: $GITHUB_REF"
- name: Show env variables list
run: env05-parallel-jobs .github/workflows/05-parallel-jobs.yml
View raw YAML
name: parallel-jobs
on:
push:
paths:
- '.github/workflows/05-parallel-jobs.yml'
jobs:
job-a:
runs-on: ubuntu-latest
steps:
- run: echo "Doing work"
job-b:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./05-parallel-jobs
run: pwd
- run: echo "More work at the same time"06-job-ordering .github/workflows/06-job-ordering.yml
View raw YAML
name: job-ordering
on:
push:
paths:
- '.github/workflows/06-job-ordering.yml'
jobs:
job1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./06-job-ordering
run: pwd
- run: echo "Doing work parallel with job2"
job2:
runs-on: ubuntu-latest
steps:
- run: echo "Doing work parallel with job1"
job3:
runs-on: ubuntu-latest
needs: job1
steps:
- run: echo "job1 done, running job3"
job4:
runs-on: ubuntu-latest
needs: [job2, job3]
steps:
- run: echo "job2 & job3 done, running job4"
job5:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: job1
steps:
- run: echo "job1 completed with status ${{ needs.job1.result }}, running job5"07-job-matrix matrix .github/workflows/07-job-matrix.yml
View raw YAML
name: job-matrix
on:
push:
paths:
- '07-job-matrix/**'
- '.github/workflows/07-job-matrix.yml'
jobs:
my-job:
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-22.04]
node: [14, 16, 18]
exclude:
- os: ubuntu-18.04
node: 14
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: Print OS-release
run: cat /etc/os-release
- name: Install dependencies
working-directory: ./07-job-matrix
run: npm ci
- name: Run tests
working-directory: ./07-job-matrix
run: npm test
08-outputs .github/workflows/08-outputs.yml
View raw YAML
name: outputs
on:
push:
paths:
- '.github/workflows/08-outputs.yml'
jobs:
job1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./08-outputs
run: pwd
- name: Do Work
run: |
echo "FAV_NUMBER=3" >> $GITHUB_OUTPUT
echo "FAV_COLOR=blue" >> $GITHUB_OUTPUT
id: abc
- name: Read output
run: |
echo "${{steps.abc.outputs.FAV_NUMBER}}"
echo "${{steps.abc.outputs.FAV_COLOR}}"
outputs:
fav-animal: tiger
fav-number: ${{steps.abc.outputs.FAV_NUMBER}}
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- run: |
echo "${{needs.job1.outputs.fav-animal}}"
echo "${{needs.job1.outputs.fav-number}}"
09-context-variables matrix .github/workflows/09-context-variables.yml
View raw YAML
name: contexts-example
on:
push:
paths:
- '09-context-variables/**'
- '.github/workflows/09-context-variables.yml'
pull_request:
paths:
- '09-context-variables/**'
- '.github/workflows/09-context-variables.yml'
jobs:
use-contexts:
runs-on: ubuntu-latest
strategy:
matrix:
greeting: [Hello, Howdy, Hey]
steps:
- uses: actions/checkout@v3
- name: Print greeting
run: echo ${{ matrix.greeting }}
env:
GREETING: ${{ matrix.greeting }}
- name: Do work with a secret
working-directory: ./09-context-variables
run: ./workRequiringASecret.sh
env:
A_SECRET: ${{ secrets.USERNAME }}
- name: Run only for pulls
if: ${{ github.event_name == 'pull_request' }}
run: echo "Triggered by a pull request"
10-context-expressions matrix .github/workflows/10-context-expressions.yml
View raw YAML
name: expressions-example
on:
push:
paths:
- '.github/workflows/10-context-expressions.yml'
jobs:
use-expressions:
strategy:
matrix:
greeting: [Hello, Howdy, Hey]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Print current path
working-directory: ./10-context-expressions
run: pwd
- name: Print if 'Hello'
if: ${{ matrix.greeting == 'Hello' }}
run: echo "greeting is Hello"
- name: Print if starts with 'He'
if: ${{ startsWith(matrix.greeting, 'He') }}
run: echo "greeting starts with He"
- name: Print if ends with 'y'
if: ${{ endsWith(matrix.greeting, 'y') }}
run: echo "greeting ends with y"
- name: Print if contains 'ow'
if: ${{ contains(matrix.greeting, 'ow') }}
run: echo "greeting contains ow"
- name: Print formatted greeting
run: |
echo "${{ format('{0} says {1}', github.actor, matrix.greeting) }}"
- name: To JSON
run: echo 'Job context is ${{ toJSON(job) }}'
- name: From JSON
env: ${{ fromJSON('{"FAVORITE_FRUIT":"APPLE", "FAVORITE_COLOR":"BLUE"}') }}
run: echo "I would like a ${FAVORITE_COLOR} ${FAVORITE_FRUIT}"
- name: Success
if: ${{ success() }}
run: echo "Still running..."
- name: Always
if: ${{ always() }}
run: echo "You will always see this"
- name: Cancelled
if: ${{ cancelled() }}
run: echo "You canceled the workflow"
- name: Failure
if: ${{ failure() }}
run: echo "Something went wrong..."11-tmate .github/workflows/11-tmate.yml
View raw YAML
name: tmate
on:
push:
paths:
- '11-tmate/**'
- '.github/workflows/11-tmate.yml'
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14
- name: Print OS-release
run: cat /etc/os-release
- name: Run tests
working-directory: ./11-tmate
run: npm test
- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3.11
12-postgres-example .github/workflows/12-postgres-example.yml
View raw YAML
name: PostgreSQL Service Example
on:
push:
paths:
- '.github/workflows/12-postgres-example.yml'
jobs:
postgres-job:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
# Maps TCP port 5432 in the service container to a randomly chosen available port on the host.
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: run postgres
run: pg_isready -h localhost13-get-secret-value .github/workflows/13-get-secret-value.yml
View raw YAML
name: Get secret value
on:
push:
paths:
- '.github/workflows/13-get-secret-value.yml'
# Create a secret with the name `NEW_SECRET` or replace it with the name of the existing secret to see the value of secret
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Echo secret's value
run: |
echo "MASKED=${{ secrets.NEW_SECRET }}" >> $GITHUB_ENV
- name: Echo unmasked secret's value
run: |
echo ${{ secrets.NEW_SECRET }} | sed 's/./& /g' | sed 's/ //g'
unmasked=$(echo ${{ secrets.NEW_SECRET }} | sed 's/./& /g' | sed 's/ //g')
echo "UNMASKED=$unmasked" >> $GITHUB_ENV
- name: Echo env secrets
run: |
echo "masked: ${{ env.MASKED }}"
echo "unmasked: ${{ env.UNMASKED }}"