From b63ede2105df6512bc821f4d09268e9be57c383f Mon Sep 17 00:00:00 2001 From: Sophie Wigmore Date: Wed, 21 Sep 2022 17:59:47 -0400 Subject: [PATCH] update workflows to use github-config/library --- .github/.patch_files | 19 ++++ .github/.syncignore | 3 + .github/dependabot.yml | 2 +- .github/labels.yml | 36 +++++++ ...approve-bot-prs.yml => approve-bot-pr.yml} | 2 +- .github/workflows/codeql-analysis.yml | 39 ++++++++ .github/workflows/create-draft-release.yml | 93 +++++++++++++++++++ .github/workflows/create-release.yml | 53 ----------- .github/workflows/label-pr.yml | 34 +++++++ .github/workflows/lint-yaml.yml | 30 ++++++ .github/workflows/lint.yml | 20 +++- .github/workflows/synchronize-labels.yml | 20 ++++ .github/workflows/test-pull-request.yml | 7 +- .github/workflows/update-github-config.yml | 62 +++++++++++++ 14 files changed, 358 insertions(+), 62 deletions(-) create mode 100644 .github/.patch_files create mode 100644 .github/.syncignore create mode 100644 .github/labels.yml rename .github/workflows/{approve-bot-prs.yml => approve-bot-pr.yml} (98%) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/create-draft-release.yml delete mode 100644 .github/workflows/create-release.yml create mode 100644 .github/workflows/label-pr.yml create mode 100644 .github/workflows/lint-yaml.yml create mode 100644 .github/workflows/synchronize-labels.yml create mode 100644 .github/workflows/update-github-config.yml diff --git a/.github/.patch_files b/.github/.patch_files new file mode 100644 index 0000000..346d63b --- /dev/null +++ b/.github/.patch_files @@ -0,0 +1,19 @@ +.github/.patch_files +.github/labels.yml +.github/CODEOWNERS +.github/workflows +.github/workflows/approve-bot-pr.yml +.github/workflows/codeql-analysis.yml +.github/workflows/lint.yml +.github/workflows/update-github-config.yml +.github/workflows/create-draft-release.yml +.github/workflows/test-pull-request.yml +.github/workflows/lint-yaml.yml +.github/workflows/synchronize-labels.yml +.github/workflows/label-pr.yml +.github/.syncignore +.github/dependabot.yml +.gitignore +LICENSE +NOTICE +README.md diff --git a/.github/.syncignore b/.github/.syncignore new file mode 100644 index 0000000..8ccd18e --- /dev/null +++ b/.github/.syncignore @@ -0,0 +1,3 @@ +workflows/test-pull-request.yml +workflows/create-draft-release.yml +CODEOWNERS diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d921d0f..bf49a9d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,7 +1,7 @@ +--- version: 2 updates: - package-ecosystem: gomod directory: "/" schedule: interval: daily - open-pull-requests-limit: 10 diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..f6526ba --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,36 @@ +- name: status/possible-priority + description: This issue is ready to work and should be considered as a potential priority + color: F9D0C4 +- name: status/prioritized + description: This issue has been triaged and resolving it is a priority + color: BFD4F2 +- name: status/blocked + description: This issue has been triaged and resolving it is blocked on some other issue + color: 848978 +- name: bug + description: Something isn't working + color: d73a4a +- name: enhancement + description: A new feature or request + color: a2eeef +- name: documentation + description: This issue relates to writing documentation + color: D4C5F9 +- name: semver:major + description: A change requiring a major version bump + color: 6b230e +- name: semver:minor + description: A change requiring a minor version bump + color: cc6749 +- name: semver:patch + description: A change requiring a patch version bump + color: f9d0c4 +- name: good first issue + description: A good first issue to get started with + color: d3fc03 +- name: "failure:release" + description: An issue filed automatically when a release workflow run fails + color: f00a0a +- name: "failure:push" + description: An issue filed automatically when a push buildpackage workflow run fails + color: f00a0a diff --git a/.github/workflows/approve-bot-prs.yml b/.github/workflows/approve-bot-pr.yml similarity index 98% rename from .github/workflows/approve-bot-prs.yml rename to .github/workflows/approve-bot-pr.yml index 1f28143..9388116 100644 --- a/.github/workflows/approve-bot-prs.yml +++ b/.github/workflows/approve-bot-pr.yml @@ -1,4 +1,4 @@ -name: Approve Bot PRs +name: Approve Bot PRs and Enable Auto-Merge on: workflow_run: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..13d5249 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,39 @@ +name: "CodeQL" + +on: + push: + branches: + - main + - v* + pull_request: + branches: + - main + - v* + schedule: + - cron: '0 0 * * *' # Once a day at midnight + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: + - 'go' + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/create-draft-release.yml b/.github/workflows/create-draft-release.yml new file mode 100644 index 0000000..7692bc6 --- /dev/null +++ b/.github/workflows/create-draft-release.yml @@ -0,0 +1,93 @@ +name: Create or Update Draft Release + +on: + push: + branches: + - main + - v* + repository_dispatch: + types: [ version-bump ] + workflow_dispatch: + inputs: + version: + description: 'Version of the release to cut (e.g. 1.2.3)' + required: false + +concurrency: release + +jobs: + unit: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.x + - name: Checkout + uses: actions/checkout@v3 + - name: Run Unit Tests + run: go test -v -count=1 ./... + + release: + name: Release + runs-on: ubuntu-latest + needs: unit + steps: + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.x + - name: Checkout + uses: actions/checkout@v3 + - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true + - name: Reset Draft Release + id: reset + uses: paketo-buildpacks/github-config/actions/release/reset-draft@main + with: + repo: ${{ github.repository }} + token: ${{ github.token }} + - name: Calculate Semver Tag + if: github.event.inputs.version == '' + id: semver + uses: paketo-buildpacks/github-config/actions/tag/calculate-semver@main + with: + repo: ${{ github.repository }} + token: ${{ github.token }} + ref-name: ${{ github.ref_name }} + - name: Set Release Tag + id: tag + run: | + tag="${{ github.event.inputs.version }}" + if [ -z "${tag}" ]; then + tag="${{ steps.semver.outputs.tag }}" + fi + echo "::set-output name=tag::${tag}" + - name: Create Release + uses: paketo-buildpacks/github-config/actions/release/create@main + with: + repo: ${{ github.repository }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + tag_name: v${{ steps.tag.outputs.tag }} + target_commitish: ${{ github.sha }} + name: v${{ steps.tag.outputs.tag }} + draft: true + + failure: + name: Alert on Failure + runs-on: ubuntu-latest + needs: [ unit, release ] + if: ${{ always() && needs.unit.result == 'failure' || needs.release.result == 'failure' }} + steps: + - name: File Failure Alert Issue + uses: paketo-buildpacks/github-config/actions/issue/file@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + repo: ${{ github.repository }} + label: "failure:release" + comment_if_exists: true + issue_title: "Failure: Create Draft Release workflow" + issue_body: | + Create Draft Release workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). + comment_body: | + Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index ae56b1a..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Create Release - -on: - push: - branches: - - main - -jobs: - unit: - name: Unit Tests - runs-on: ubuntu-latest - steps: - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.18.x - - name: Checkout - uses: actions/checkout@v2 - - name: Run Unit Tests - run: go test -v -count=1 ./... - - release: - name: Release - runs-on: ubuntu-latest - needs: unit - steps: - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.18.x - - name: Checkout - uses: actions/checkout@v2 - - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true - - name: Reset Draft Release - id: reset - uses: paketo-buildpacks/github-config/actions/release/reset-draft@main - with: - repo: ${{ github.repository }} - token: ${{ github.token }} - - name: Tag - id: tag - uses: paketo-buildpacks/github-config/actions/tag/increment-tag@main - with: - current_version: ${{ steps.reset.outputs.current_version }} - - name: Create Draft Release - uses: paketo-buildpacks/github-config/actions/release/create@main - with: - repo: ${{ github.repository }} - token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} - tag_name: v${{ steps.tag.outputs.tag }} - target_commitish: ${{ github.sha }} - name: v${{ steps.tag.outputs.tag }} - draft: true diff --git a/.github/workflows/label-pr.yml b/.github/workflows/label-pr.yml new file mode 100644 index 0000000..cfc9f3a --- /dev/null +++ b/.github/workflows/label-pr.yml @@ -0,0 +1,34 @@ +name: Set / Validate PR Labels +on: + pull_request_target: + branches: + - main + - v* + types: + - synchronize + - opened + - reopened + - labeled + - unlabeled + +concurrency: pr_labels_${{ github.event.number }} + +jobs: + autolabel: + name: Ensure Minimal Semver Labels + runs-on: ubuntu-latest + steps: + - name: Check Minimal Semver Labels + uses: mheap/github-action-required-labels@v1 + with: + count: 1 + labels: semver:major, semver:minor, semver:patch + mode: exactly + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Auto-label Semver + if: ${{ failure() }} + uses: paketo-buildpacks/github-config/actions/pull-request/auto-semver-label@main + env: + GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/lint-yaml.yml b/.github/workflows/lint-yaml.yml new file mode 100644 index 0000000..f0ef713 --- /dev/null +++ b/.github/workflows/lint-yaml.yml @@ -0,0 +1,30 @@ +name: Lint Workflows + +on: + pull_request: + paths: + - '.github/**.yml' + - '.github/**.yaml' + +jobs: + lintYaml: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Checkout github-config + uses: actions/checkout@v3 + with: + repository: paketo-buildpacks/github-config + path: github-config + + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: 3.8 + + - name: Install yamllint + run: pip install yamllint + + - name: Lint YAML files + run: yamllint ./.github -c github-config/.github/.yamllint diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4d99a4f..2735f4f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,17 +4,27 @@ on: push: branches: - main + - v* pull_request: branches: - main + - v* jobs: golangci: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: golangci-lint - uses: golangci/golangci-lint-action@v2.3.0 - with: - version: v1.45.2 + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.18.x + + - name: Checkout + uses: actions/checkout@v3 + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + version: latest + args: --timeout 3m0s diff --git a/.github/workflows/synchronize-labels.yml b/.github/workflows/synchronize-labels.yml new file mode 100644 index 0000000..e7b87c4 --- /dev/null +++ b/.github/workflows/synchronize-labels.yml @@ -0,0 +1,20 @@ +name: Synchronize Labels + +on: + push: + branches: + - main + - v* + paths: + - .github/labels.yml + +jobs: + synchronize: + name: Synchronize Labels + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: micnncim/action-label-syncer@v1 + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/test-pull-request.yml b/.github/workflows/test-pull-request.yml index 424f2ec..daa81c5 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main + - v* jobs: unit: @@ -13,9 +14,11 @@ jobs: - name: Setup Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.18.x + - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Run Unit Tests run: go test -v -count=1 ./... diff --git a/.github/workflows/update-github-config.yml b/.github/workflows/update-github-config.yml new file mode 100644 index 0000000..e413e28 --- /dev/null +++ b/.github/workflows/update-github-config.yml @@ -0,0 +1,62 @@ +name: Update shared github-config + +on: + schedule: + - cron: '30 1 * * *' + workflow_dispatch: {} + +concurrency: github_config_update + +jobs: + build: + name: Create PR to update shared files + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + + - name: Checkout github-config + uses: actions/checkout@v3 + with: + repository: paketo-buildpacks/github-config + path: github-config + + - name: Checkout Branch + uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main + with: + branch: automation/github-config/update + + - name: Run the sync action + uses: paketo-buildpacks/github-config/actions/sync@main + with: + workspace: /github/workspace + config: /github/workspace/github-config/library + + - name: Cleanup + run: rm -rf github-config + + - name: Commit + id: commit + uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main + with: + message: "Updating github-config" + pathspec: "." + keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }} + key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }} + + - name: Push Branch + if: ${{ steps.commit.outputs.commit_sha != '' }} + uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main + with: + branch: automation/github-config/update + + - name: Open Pull Request + if: ${{ steps.commit.outputs.commit_sha != '' }} + uses: paketo-buildpacks/github-config/actions/pull-request/open@main + with: + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + title: "Updates github-config" + branch: automation/github-config/update