From 12245153cd7993588613044647cf05294abaa96f Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Mon, 29 Aug 2022 22:18:36 -0500 Subject: [PATCH] Standardize workflows to appear more similar to github-config --- .github/.patch_files | 15 +++++---- .github/.syncignore | 1 + .github/dependabot.yml | 1 + .github/labels.yml | 18 +++++++++++ ...approve-bot-prs.yml => approve-bot-pr.yml} | 2 +- .github/workflows/codeql-analysis.yml | 14 ++++---- ...e-release.yml => create-draft-release.yml} | 32 ++++++++++++++++--- .github/workflows/label-pr.yml | 2 +- .github/workflows/lint-yaml.yml | 30 +++++++++++++++++ .github/workflows/lint.yml | 27 +++++++++------- .github/workflows/synchronize-labels.yml | 17 +++++----- .github/workflows/test-pull-request.yml | 6 ++-- 12 files changed, 123 insertions(+), 42 deletions(-) create mode 100644 .github/.syncignore rename .github/workflows/{approve-bot-prs.yml => approve-bot-pr.yml} (98%) rename .github/workflows/{create-release.yml => create-draft-release.yml} (63%) create mode 100644 .github/workflows/lint-yaml.yml diff --git a/.github/.patch_files b/.github/.patch_files index cf0b1787..65270276 100644 --- a/.github/.patch_files +++ b/.github/.patch_files @@ -1,14 +1,17 @@ .github/.patch_files -.github/.syncignore -.github/CODEOWNERS -.github/dependabot.yml .github/labels.yml -.github/workflows/check-pr-labels.yml +.github/CODEOWNERS +.github/workflows +.github/workflows/approve-bot-pr.yml .github/workflows/codeql-analysis.yml -.github/workflows/label-pr.yml .github/workflows/lint.yml -.github/workflows/synchronize-labels.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 diff --git a/.github/.syncignore b/.github/.syncignore new file mode 100644 index 00000000..7c0127a9 --- /dev/null +++ b/.github/.syncignore @@ -0,0 +1 @@ +CODEOWNERS diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d921d0ff..dd4beec2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,3 +1,4 @@ +--- version: 2 updates: - package-ecosystem: gomod diff --git a/.github/labels.yml b/.github/labels.yml index bace6e20..f6526ba2 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -16,3 +16,21 @@ - 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 1f28143f..93881160 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 index a44451d6..13d5249b 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -4,13 +4,13 @@ on: push: branches: - main - - v2 + - v* pull_request: branches: - main - - v2 + - v* schedule: - - cron: '0 0 * * *' # Once a day at midnight + - cron: '0 0 * * *' # Once a day at midnight jobs: analyze: @@ -25,15 +25,15 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: languages: ${{ matrix.language }} - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-draft-release.yml similarity index 63% rename from .github/workflows/create-release.yml rename to .github/workflows/create-draft-release.yml index 089a0186..7692bc6d 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-draft-release.yml @@ -1,9 +1,12 @@ -name: Create Release +name: Create or Update Draft Release on: push: branches: - - v2 + - main + - v* + repository_dispatch: + types: [ version-bump ] workflow_dispatch: inputs: version: @@ -22,7 +25,7 @@ jobs: with: 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 ./... @@ -36,7 +39,7 @@ jobs: with: go-version: 1.18.x - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true - name: Reset Draft Release id: reset @@ -60,7 +63,7 @@ jobs: tag="${{ steps.semver.outputs.tag }}" fi echo "::set-output name=tag::${tag}" - - name: Create Draft Release + - name: Create Release uses: paketo-buildpacks/github-config/actions/release/create@main with: repo: ${{ github.repository }} @@ -69,3 +72,22 @@ jobs: 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/label-pr.yml b/.github/workflows/label-pr.yml index 12924696..cfc9f3af 100644 --- a/.github/workflows/label-pr.yml +++ b/.github/workflows/label-pr.yml @@ -3,7 +3,7 @@ on: pull_request_target: branches: - main - - v2 + - v* types: - synchronize - opened diff --git a/.github/workflows/lint-yaml.yml b/.github/workflows/lint-yaml.yml new file mode 100644 index 00000000..f0ef7133 --- /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 0e764408..2735f4fc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,24 +4,27 @@ on: push: branches: - main - - v2 + - v* pull_request: branches: - main - - v2 + - v* jobs: golangci: name: lint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Go - uses: actions/setup-go@v3 - with: - go-version: 1.18.x - - name: golangci-lint - uses: golangci/golangci-lint-action@v2.3.0 - with: - version: latest - args: "--timeout 3m0s" + - 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 index 892aad81..e7b87c44 100644 --- a/.github/workflows/synchronize-labels.yml +++ b/.github/workflows/synchronize-labels.yml @@ -1,19 +1,20 @@ name: Synchronize Labels + on: push: branches: - - main - - v2 + - main + - v* paths: - - .github/labels.yml + - .github/labels.yml jobs: synchronize: name: Synchronize Labels runs-on: - - ubuntu-latest + - ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: micnncim/action-label-syncer@v1 - env: - GITHUB_TOKEN: ${{ github.token }} + - 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 fd8171d7..daa81c56 100644 --- a/.github/workflows/test-pull-request.yml +++ b/.github/workflows/test-pull-request.yml @@ -4,7 +4,7 @@ on: pull_request: branches: - main - - v2 + - v* jobs: unit: @@ -15,8 +15,10 @@ jobs: uses: actions/setup-go@v3 with: 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 ./...