diff --git a/.github/workflows/generate-dependabot-config.md b/.github/workflows/generate-dependabot-config.md index 0bd0b22..e97f875 100644 --- a/.github/workflows/generate-dependabot-config.md +++ b/.github/workflows/generate-dependabot-config.md @@ -1,14 +1,21 @@ -# Workflow - Generate Dependabot Config + -Reusable workflow to generate a dependabot config from predefined templates. +# GitHub Reusable Workflow: Generate Dependabot Config -Mainly using [Generate Dependabot Glob Action](https://github.com/marketplace/actions/generate-dependabot-glob), to generate a dependabot config from a glob pattern. + + +Reusable workflow to generate a dependabot config from predefined templates. +Mainly using [Generate Dependabot Glob Action](https://github.com/marketplace/actions/generate-dependabot-glob), to generate a dependabot config from a glob pattern. Workaround for missing official support of glob directories [https://github.com/dependabot/dependabot-core/issues/2178](https://github.com/dependabot/dependabot-core/issues/2178) -## Usage + + + + ```yaml +name: Generate dependabot.yml config on: push: branches: @@ -17,3 +24,15 @@ jobs: main: uses: hoverkraft-tech/ci-github-common/.github/workflows/generate-dependabot-config.yml@main ``` + + + + + + + + + + + + diff --git a/.github/workflows/greetings.md b/.github/workflows/greetings.md index 4f58c5b..e0df2e0 100644 --- a/.github/workflows/greetings.md +++ b/.github/workflows/greetings.md @@ -1,18 +1,66 @@ -# Workflow - Greetings + + +# GitHub Reusable Workflow: Greetings + + + Workflow to greet new contributors. +Mainly using [First Interaction Action](https://github.com/actions/first-interaction), with some opinionated defaults. - On issue creation, a comment is added to the issue. - On first contribution, a comment is added to the pull request. -## Usage + + + + + +```yaml +name: Mark stale issues and pull requests + +on: + schedule: + - cron: "30 1 * * *" + +jobs: + main: + uses: hoverkraft-tech/ci-github-common/.github/workflows/greetings.yml@main + secrets: + # Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". + # See https://github.com/actions/first-interaction#usage + github-token: ${{ secrets.GITHUB_TOKEN }} + + # Optional customizations. + with: + # Comment to post on an individual's first issue. + # See https://github.com/actions/first-interaction#usage + # Default: "Hi, thank for reporting an issue, we will check it out very soon" + issue-message: "" + # Comment to post on an individual's first pull request. + # See https://github.com/actions/first-interaction#usage + # Default: "Hi, thank you for creating your PR, we will check it out very soon" + pr-message: "" +``` + + + + +| **Secret** | **Description** | +| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| **github-token** | Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". See https://github.com/actions/first-interaction#usage | + + + -### As required workflow +| **Input** | **Description** | **Default** | **Required** | +| ------------------------------ | ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------ | +| **issue-message** | Comment to post on an individual's first issue. See https://github.com/actions/first-interaction#usage | Hi, thank for reporting an issue, we will check it out very soon | **false** | +| **issue-message** | Comment to post on an individual's first pull request. See https://github.com/actions/first-interaction#usage | Hi, thank you for creating your PR, we will check it out very soon | **false** | -Configure workflow to be required in your organization settings. + -- Go to your organization actions settings to add a new required workflow: Settings > Actions > General > Required workflows > Add workflow - `https://github.com/organizations/[your-organization]/settings/actions/required_workflows/new` (replace `[your-organization]` with your organization name) -- Select the repository `ci-github-common` -- Select the workflow file: `.github/workflows/greetings.yml` -- Add workflow + + + + diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 3c4e481..81517f9 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -18,7 +18,7 @@ on: required: false secrets: github-token: - description: "Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }}. See https://github.com/actions/first-interaction#usage" + description: 'Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". See https://github.com/actions/first-interaction#usage' required: true jobs: diff --git a/.github/workflows/semantic-pull-request.md b/.github/workflows/semantic-pull-request.md index 96837e2..6db25d8 100644 --- a/.github/workflows/semantic-pull-request.md +++ b/.github/workflows/semantic-pull-request.md @@ -1,16 +1,51 @@ -# Workflow - Semantic pull request + + +# GitHub Reusable Workflow: Semantic pull request + + + Workflow to ensure "Squash and merge" Pull Request strategy provides a valid commit message. Check that the title follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. +Mainly using [action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request#installation), with some opinionated defaults. + + + + + + +```yaml +name: "Pull Request - Semantic Lint" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@main + secrets: + # Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". + # See https://github.com/amannn/action-semantic-pull-request#installation + github-token: ${{ secrets.GITHUB_TOKEN }} +``` + + + -## Usage +| **Secret** | **Description** | +| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **github-token** | Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". See https://github.com/amannn/action-semantic-pull-request#installation | -### As required workflow + + -Configure workflow to be required in your organization settings. + -- Go to your organization actions settings to add a new required workflow: Settings > Actions > General > Required workflows > Add workflow - `https://github.com/organizations/[your-organization]/settings/actions/required_workflows/new` (replace `[your-organization]` with your organization name) -- Select the repository `ci-github-common` -- Select the workflow file: `.github/workflows/semantic-pull-request.yml` -- Add workflow + + + + diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml index 5402362..04352c2 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/semantic-pull-request.yml @@ -7,12 +7,22 @@ on: - opened - edited - synchronize + workflow_call: + secrets: + github-token: + description: 'Token for the repository. Can be passed in using "${{ secrets.GITHUB_TOKEN }}". See https://github.com/amannn/action-semantic-pull-request#installation' + required: true jobs: main: name: Validate PR title runs-on: ubuntu-latest steps: + - id: set-variables + run: | + GITHUB_TOKEN="${{ secrets.github-token }}" + echo "REPO_TOKEN=${GITHUB_TOKEN:-"${{ secrets.GITHUB_TOKEN }}"}" >> "$GITHUB_ENV" + - uses: amannn/action-semantic-pull-request@v5 env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ env.REPO_TOKEN }} diff --git a/.github/workflows/stale.md b/.github/workflows/stale.md index d91bd75..c99abeb 100644 --- a/.github/workflows/stale.md +++ b/.github/workflows/stale.md @@ -1,19 +1,76 @@ -# Workflow - Stale + -Workflow to mark issues and pull requests as stale when needed. +# GitHub Reusable Workflow: Stale -- First add labels to issues and pull requests to mark them as stale. -- Then add a comment to the issue or pull request to explain why it is marked as stale. -- Finally, close the issue or pull request if it is still stale after a given period of time. + + -## Usage +Reusable workflow to manage stale issues and pull requests. +Mainly using [Stale Action](https://github.com/actions/stale), with some opinionated defaults. -### As required workflow + + + + -Configure workflow to be required in your organization settings. +```yaml +name: Mark stale issues and pull requests -- Go to your organization actions settings to add a new required workflow: Settings > Actions > General > Required workflows > Add workflow - `https://github.com/organizations/[your-organization]/settings/actions/required_workflows/new` (replace `[your-organization]` with your organization name) -- Select the repository `ci-github-common` -- Select the workflow file: `.github/workflows/stale.yml` -- Add workflow +on: + schedule: + - cron: "30 1 * * *" + +jobs: + main: + uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@main + + # Optional customizations. + with: + # Comment on the staled issues. + # See https://github.com/actions/stale#stale-issue-message + # Default: "This issue is stale" + stale-issue-message: "" + + # Comment on the staled PRs. + # See https://github.com/actions/stale#stale-pr-message + # Default: "This PR is stale" + stale-pr-message: "" + + # Label to apply on staled issues. + # See https://github.com/actions/stale#stale-issue-label + # Default: "no-issue-activity" + stale-issue-label: "" + + # Labels on issues exempted from stale. + # See https://github.com/actions/stale#exempt-issue-labels + # Default: "awaiting-approval,work-in-progress" + exempt-issue-labels: "" + + # Label to apply on staled PRs. + # See https://github.com/actions/stale#stale-pr-label + # Default: "no-pr-activity" + stale-pr-label: "" + + # Labels on PRs exempted from stale. + # See https://github.com/actions/stale#exempt-pr-labels + # Default: "awaiting-approval,work-in-progress" + exempt-pr-labels: "" +``` + + + + +| **Input** | **Description** | **Default** | **Required** | +| ------------------------------------ | ---------------------------------------------------------------------------------------------- | ----------------------------------------------- | ------------ | +| **stale-issue-message** | Comment on the staled issues. See https://github.com/actions/stale#stale-issue-message | This issue is stale | **false** | +| **stale-pr-message** | Comment on the staled PRs. See https://github.com/actions/stale#stale-pr-message | This PR is stale | **false** | +| **stale-issue-label** | Label to apply on staled issues. See https://github.com/actions/stale#stale-issue-label | no-issue-activity | **false** | +| **exempt-issue-labels** | Labels on issues exempted from stale. See https://github.com/actions/stale#exempt-issue-labels | awaiting-approval,work-in-progress | **false** | +| **stale-pr-label** | Label to apply on staled PRs. See https://github.com/actions/stale#stale-pr-label | no-pr-activity | **false** | +| **exempt-pr-labels** | Labels on PRs exempted from stale. See https://github.com/actions/stale#exempt-pr-labels | awaiting-approval,work-in-progress | **false** | + + + + + + diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 98e1e88..ac989ee 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -4,17 +4,62 @@ on: schedule: - cron: "30 1 * * *" + workflow_call: + inputs: + stale-issue-message: + description: "Comment on the staled issues. See https://github.com/actions/stale#stale-issue-message" + type: string + required: false + stale-pr-message: + description: "Comment on the staled PRs. See https://github.com/actions/stale#stale-pr-message" + type: string + required: false + stale-issue-label: + description: "Label to apply on staled issues. See https://github.com/actions/stale#stale-issue-label" + type: string + required: false + exempt-issue-labels: + description: "Labels on issues exempted from stale. See https://github.com/actions/stale#exempt-issue-labels" + type: string + required: false + stale-pr-label: + description: "Label to apply on staled PRs. See https://github.com/actions/stale#stale-pr-label" + type: string + required: false + exempt-pr-labels: + description: "Labels on PRs exempted from stale. See https://github.com/actions/stale#exempt-pr-labels" + type: string + required: false + secrets: + github-token: + description: "Token for the repository. Can be passed in using {{ secrets.GITHUB_TOKEN }}. See https://github.com/actions/first-interaction#usage" + required: true + jobs: stale: runs-on: ubuntu-latest steps: + - id: set-variables + run: | + STALE_ISSUE_MESSAGE="${{ inputs.stale-issue-message }}" + echo "stale-issue-message=${STALE_ISSUE_MESSAGE:-"This issue is stale"}" >> "$GITHUB_OUTPUT" + STALE_PR_MESSAGE="${{ inputs.stale-pr-message }}" + echo "stale-pr-message=${STALE_PR_MESSAGE:-"This PR is stale"}" >> "$GITHUB_OUTPUT" + STALE_ISSUE_LABEL="${{ inputs.stale-issue-label }}" + echo "stale-issue-label=${STALE_ISSUE_LABEL:-"no-issue-activity"}" >> "$GITHUB_OUTPUT" + EXEMPT_ISSUE_LABELS="${{ inputs.exempt-issue-labels }}" + echo "exempt-issue-labels=${EXEMPT_ISSUE_LABELS:-"awaiting-approval,work-in-progress"}" >> "$GITHUB_OUTPUT" + STALE_PR_LABEL="${{ inputs.stale-pr-label }}" + echo "stale-pr-label=${STALE_PR_LABEL:-"no-pr-activity"}" >> "$GITHUB_OUTPUT" + EXEMPT_PR_LABELS="${{ inputs.exempt-pr-labels }}" + echo "exempt-pr-labels=${EXEMPT_PR_LABELS:-"awaiting-approval,work-in-progress"}" >> "$GITHUB_OUTPUT" + - uses: actions/stale@v7 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: "This issue is stale" - stale-pr-message: "This PR is stale" - stale-issue-label: "no-issue-activity" - exempt-issue-labels: "awaiting-approval,work-in-progress" - stale-pr-label: "no-pr-activity" - exempt-pr-labels: "awaiting-approval,work-in-progress" + stale-issue-message: ${{ steps.set-variables.outputs.stale-issue-message }} + stale-pr-message: ${{ steps.set-variables.outputs.stale-pr-message }} + stale-issue-label: ${{ steps.set-variables.outputs.stale-issue-label }} + exempt-issue-labels: ${{ steps.set-variables.outputs.exempt-issue-labels }} + stale-pr-label: ${{ steps.set-variables.outputs.stale-pr-label }} + exempt-pr-labels: ${{ steps.set-variables.outputs.exempt-pr-labels }} diff --git a/README.md b/README.md index 8fb7866..ea30fe5 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Opinionated GitHub actions and workflows for common continuous integration needs ### - [Slugify](actions/slugify/README.md) -## Workflows +## Reusable Workflows ### - [Generate dependabot config](.github/workflows/generate-dependabot-config.md)