Skip to content

Commit

Permalink
Consolidate shared workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha committed May 15, 2024
1 parent aef3a53 commit ae1e069
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/shared-github-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Shared github action workflow"
```
on:
workflow_call:
inputs:
organization:
description: "Repository owner organization (ex. acme for repo acme/example)"
required: false
default: ${{ github.event.repository.owner.login }}
type: string
repository:
description: "Repository name (ex. example for repo acme/example)"
required: false
default: ${{ github.event.repository.name }}
type: string
ref:
description: "The fully-formed ref of the branch or tag that triggered the workflow run"
required: false
default: ${{ github.ref }}
type: string
tests-prefix:
description: "Workflows file name prefix to run as tests"
required: false
type: string
default: 'test-*'
publish:
description: "Whether to publish a new release immediately"
required: false
default: "true"
type: string
runs-on:
description: "Overrides job runs-on setting (json-encoded list)"
type: string
required: false
default: '["ubuntu-latest"]'
permissions:
contents: write
actions: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
ci-readme:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-readme.yml@main
if: ${{ github.event_name == 'push' }}
with:
filter-mode: nofilter
suggestions: false
runs-on: ${{ inputs.runs-on }}
secrets: inherit
ci-gha:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-github-action.yml@main
with:
organization: ${{ inputs.organization }}
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
tests-prefix: ${{ inputs.tests-prefix }}
ci:
runs-on: ${{ fromJSON(inputs.runs-on) }}
if: ${{ always() }}
steps:
- run: |
echo '${{ toJSON(needs) }}' # easier debug
! ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
needs: [ ci-gha, ci-readme ]
release:
needs: [ ci ]
if: ${{ github.event_name == 'push' }}
uses: cloudposse/.github/.github/workflows/shared-auto-release.yml@main
with:
publish: ${{ inputs.publish }}
secrets: inherit
26 changes: 26 additions & 0 deletions .github/workflows/shared-terraform-chatops.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Shared Terraform ChatOps"

on:
workflow_call:
inputs:
runs-on:
description: "Overrides job runs-on setting (json-encoded list)"
type: string
required: false
default: '["ubuntu-latest"]'
secrets:
github_access_token:
description: "GitHub API token"
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
ci-terraform-chatops:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-terraform-chatops.yml@main
with:
runs-on: ${{ inputs.runs-on }}
secrets:
github_access_token: ${{ secrets.github_access_token }}
65 changes: 65 additions & 0 deletions .github/workflows/shared-terraform-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Shared terraform module"
on:
workflow_call:
inputs:
runs-on:
description: "Overrides job runs-on setting (json-encoded list)"
type: string
required: false
default: '["ubuntu-latest"]'
secrets:
REPO_ACCESS_TOKEN:
description: "GitHub API token"
required: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
ci-terraform:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-terraform.yml@main
with:
# Workaround for https://github.com/community/community/discussions/9099
# We should switch to nofilter once it's fixed
filter-mode: diff_context // nofilter
suggestions: ${{ github.event_name == 'pull_request' }}
runs-on: ${{ inputs.runs-on }}

ci-readme:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-readme.yml@main
if: ${{ github.event_name == 'push' }}
with:
runs-on: ${{ inputs.runs-on }}
secrets: inherit

ci-codeowners:
uses: cloudposse/github-actions-workflows/.github/workflows/ci-codeowners.yml@main
with:
is_fork: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
runs-on: ${{ inputs.runs-on }}
secrets:
github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}

ci-labels:
runs-on: ${{ fromJSON(inputs.runs-on) }}
steps:
- uses: cloudposse/github-action-release-label-validator@v1

ci:
runs-on: ${{ fromJSON(inputs.runs-on) }}
if: ${{ always() }}
steps:
- run: |
echo '${{ toJSON(needs) }}' # easier debug
! ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
needs: [ ci-terraform, ci-readme, ci-codeowners, ci-labels ]

auto-release:
needs: [ci]
uses: cloudposse/.github/.github/workflows/shared-auto-release.yml@main
if: ${{ github.event_name == 'push' }}
with:
runs-on: ${{ inputs.runs-on }}
publish: true
secrets: inherit
32 changes: 32 additions & 0 deletions .github/workflows/shared-terraform-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: "Shared terraform scheduled"

on:
workflow_call:
inputs:
runs-on:
description: "Overrides job runs-on setting (json-encoded list)"
type: string
required: false
default: '["ubuntu-latest"]'
secrets:
REPO_ACCESS_TOKEN:
description: "GitHub API token"
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
context:
uses: cloudposse/github-actions-workflows/.github/workflows/scheduled-context.yml@main
with:
runs-on: ${{ inputs.runs-on }}
secrets:
github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}

readme:
uses: cloudposse/github-actions-workflows/.github/workflows/scheduled-readme.yml@main
with:
runs-on: ${{ inputs.runs-on }}
secrets: inherit

0 comments on commit ae1e069

Please sign in to comment.