Skip to content

Commit

Permalink
update workflows to use github-config/library
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiewigmore committed Sep 26, 2022
1 parent 41ec9e6 commit b63ede2
Show file tree
Hide file tree
Showing 14 changed files with 358 additions and 62 deletions.
19 changes: 19 additions & 0 deletions .github/.patch_files
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .github/.syncignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
workflows/test-pull-request.yml
workflows/create-draft-release.yml
CODEOWNERS
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
36 changes: 36 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Approve Bot PRs
name: Approve Bot PRs and Enable Auto-Merge

on:
workflow_run:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -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
93 changes: 93 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -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}}
53 changes: 0 additions & 53 deletions .github/workflows/create-release.yml

This file was deleted.

34 changes: 34 additions & 0 deletions .github/workflows/label-pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
30 changes: 30 additions & 0 deletions .github/workflows/lint-yaml.yml
Original file line number Diff line number Diff line change
@@ -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
20 changes: 15 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions .github/workflows/synchronize-labels.yml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit b63ede2

Please sign in to comment.