Skip to content

Commit bcdf60a

Browse files
committed
Add standard GitHub Actions workflows matching other buildpacks
1 parent b46000f commit bcdf60a

6 files changed

Lines changed: 367 additions & 0 deletions

File tree

.github/labels.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- name: status/blocked
2+
description: This issue has been triaged and resolving it is blocked on some other issue
3+
color: 848978
4+
- name: bug
5+
description: Something isn't working
6+
color: d73a4a
7+
- name: enhancement
8+
description: A new feature or request
9+
color: a2eeef
10+
- name: documentation
11+
description: This issue relates to writing documentation
12+
color: D4C5F9
13+
- name: semver:major
14+
description: A change requiring a major version bump
15+
color: 6b230e
16+
- name: semver:minor
17+
description: A change requiring a minor version bump
18+
color: cc6749
19+
- name: semver:patch
20+
description: A change requiring a patch version bump
21+
color: f9d0c4
22+
- name: good first issue
23+
description: A good first issue to get started with
24+
color: d3fc03
25+
- name: "failure:release"
26+
description: An issue filed automatically when a release workflow run fails
27+
color: f00a0a
28+
- name: "failure:push"
29+
description: An issue filed automatically when a push buildpackage workflow run fails
30+
color: f00a0a
31+
- name: dependency-deprecation
32+
description: Notice of dependency deprecation
33+
color: ffff00

.github/workflows/auto-merge.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Auto-Merge
2+
3+
on:
4+
repository_dispatch:
5+
types:
6+
- approve-bot-pr
7+
8+
jobs:
9+
automerge:
10+
name: Merge or Rebase
11+
if: ${{ github.event.client_payload.login == 'cf-buildpacks-eng' || github.event.client_payload.login == 'dependabot[bot]' }}
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Fetch Pull Request Details
19+
id: pull_request
20+
env:
21+
NUMBER: ${{ github.event.client_payload.number }}
22+
GITHUB_TOKEN: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
23+
run: |
24+
payload="$(
25+
curl "https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${NUMBER}" \
26+
--silent \
27+
--location \
28+
--header "Authorization: token ${GITHUB_TOKEN}"
29+
)"
30+
31+
echo "::set-output name=mergeable_state::$(echo "${payload}" | jq -r -c .mergeable_state)"
32+
33+
- name: Merge
34+
if: ${{ steps.pull_request.outputs.mergeable_state == 'clean' || steps.pull_request.outputs.mergeable_state == 'unstable' }}
35+
uses: paketo-buildpacks/github-config/actions/pull-request/merge@main
36+
with:
37+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
38+
number: ${{ github.event.client_payload.number }}
39+
40+
- name: Accept Tracker Story
41+
if: ${{ steps.pull_request.outputs.mergeable_state == 'clean' || steps.pull_request.outputs.mergeable_state == 'unstable' }}
42+
run: |
43+
story_id=${{ github.event.client_payload.tracker_story }}
44+
if [ "$story_id" != "-1" ]; then
45+
## Comment with Github PR link
46+
curl -X POST \
47+
-H "X-TrackerToken: ${{ secrets.TRACKER_API_TOKEN }}" \
48+
-H "Content-Type: application/json" \
49+
-d "{\"text\": \"Merged in [PR](https://www.github.com/${GITHUB_REPOSITORY}/pull/${NUMBER})\"}" \
50+
"https://www.pivotaltracker.com/services/v5/projects/${{ secrets.TRACKER_PROJECT_ID }}/stories/$story_id/comments"
51+
52+
## Accept story
53+
curl -X PUT \
54+
-H "X-TrackerToken: ${{ secrets.TRACKER_API_TOKEN }}" \
55+
-H "Content-Type: application/json" \
56+
-d '{"current_state":"accepted"}' \
57+
"https://www.pivotaltracker.com/services/v5/projects/${{ secrets.TRACKER_PROJECT_ID }}/stories/$story_id"
58+
fi
59+
60+
- name: Rebase
61+
if: ${{ steps.pull_request.outputs.mergeable_state == 'behind' }}
62+
uses: paketo-buildpacks/github-config/actions/pull-request/rebase@main
63+
with:
64+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
65+
number: ${{ github.event.client_payload.number }}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Dependency Deprecation Reminder
2+
3+
on:
4+
schedule:
5+
- cron: '5 0 * * 0'
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
reminder:
10+
name: Reminder
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
ref: master
17+
18+
- name: Get deprecations
19+
id: deprecations
20+
uses: cloudfoundry/buildpacks-github-config/actions/dependency/deprecation-list@main
21+
with:
22+
buildpack: .
23+
buffer-days: 10
24+
25+
- name: File Issue
26+
if: steps.deprecations.outputs.list != ''
27+
id: file-issue
28+
uses: paketo-buildpacks/github-config/actions/issue/file@main
29+
with:
30+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
31+
repo: ${{ github.repository }}
32+
comment_if_exists: true
33+
label: dependency-deprecation
34+
issue_title: Dependency Deprecation Alert
35+
issue_body: |
36+
Please make sure the following dependencies are removed from buildpack on time.
37+
38+
${{ steps.deprecations.outputs.list }}
39+
comment_body: |
40+
Reminder that deprecation of the following dependencies may require attention
41+
42+
${{ steps.deprecations.outputs.list }}
43+
44+
- name: Add issue to project
45+
if: steps.deprecations.outputs.list != ''
46+
id: issue-to-proj
47+
uses: paketo-buildpacks/github-config/actions/issue/add-to-project@main
48+
with:
49+
# CF buildpacks project - https://github.com/orgs/cloudfoundry/projects/37
50+
project-org: cloudfoundry
51+
project-num: 37
52+
field-name: Workstream
53+
option-name: Dependency Deprecations
54+
issue-node-id: ${{ steps.file-issue.outputs.node-id }}
55+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Synchronize Labels
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- .github/labels.yml
9+
workflow_dispatch: {}
10+
jobs:
11+
synchronize:
12+
name: Synchronize Labels
13+
runs-on:
14+
- ubuntu-22.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: micnncim/action-label-syncer@v1
18+
env:
19+
GITHUB_TOKEN: ${{ github.token }}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Test Pull Request
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
unit:
10+
name: Unit Tests
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Setup Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: stable
18+
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Run Unit Tests
25+
run: ./scripts/unit.sh
26+
27+
integration-matrix:
28+
name: Integration Matrix
29+
runs-on: ubuntu-latest
30+
outputs:
31+
matrix: ${{ steps.set-matrix.outputs.matrix }}
32+
needs: unit
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Set Matrix
38+
id: set-matrix
39+
run: |
40+
matrix="$(jq -r -c '.integration.matrix' ./config.json)"
41+
printf "Output: matrix=%s\n" "${matrix}"
42+
printf "matrix=%s\n" "${matrix}" >> "$GITHUB_OUTPUT"
43+
44+
integration:
45+
name: Integration Test
46+
runs-on: ubuntu-latest
47+
needs: integration-matrix
48+
strategy:
49+
matrix:
50+
include: ${{ fromJSON(needs.integration-matrix.outputs.matrix) }}
51+
steps:
52+
53+
- name: Setup Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: stable
57+
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Run Integration Tests
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: |
67+
./scripts/integration.sh \
68+
--platform docker \
69+
--github-token "${GITHUB_TOKEN}" \
70+
--cached ${{ matrix.cached }} \
71+
--parallel ${{ matrix.parallel }}
72+
73+
roundup:
74+
name: Integration Tests
75+
if: ${{ always() }}
76+
runs-on: ubuntu-latest
77+
needs: integration
78+
steps:
79+
- run: |
80+
result="${{ needs.integration.result }}"
81+
if [[ "${result}" == "success" ]]; then
82+
echo "All integration tests passed"
83+
exit 0
84+
else
85+
echo "One or more integration tests failed"
86+
exit 1
87+
fi
88+
89+
approve:
90+
name: Approve Bot PRs
91+
if: ${{ github.event.pull_request.user.login == 'cf-buildpacks-eng' || github.event.pull_request.user.login == 'dependabot[bot]' }}
92+
runs-on: ubuntu-latest
93+
needs: roundup
94+
steps:
95+
96+
- name: Check Commit Verification
97+
id: unverified-commits
98+
uses: paketo-buildpacks/github-config/actions/pull-request/check-unverified-commits@main
99+
with:
100+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
101+
repo: ${{ github.repository }}
102+
number: ${{ github.event.number }}
103+
104+
- name: Check for Human Commits
105+
id: human-commits
106+
uses: paketo-buildpacks/github-config/actions/pull-request/check-human-commits@main
107+
with:
108+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
109+
repo: ${{ github.repository }}
110+
number: ${{ github.event.number }}
111+
bots: 'dependabot[bot],web-flow,cf-buildpacks-eng'
112+
113+
- name: Checkout
114+
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
115+
uses: actions/checkout@v2
116+
with:
117+
ref: ${{ github.event.pull_request.head.sha }}
118+
119+
- name: Dispatch
120+
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
121+
uses: paketo-buildpacks/github-config/actions/dispatch@main
122+
with:
123+
repos: ${{ github.repository }}
124+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
125+
event: approve-bot-pr
126+
payload: |
127+
{
128+
"number": "${{ github.event.pull_request.number }}",
129+
"login": "${{ github.event.pull_request.user.login }}",
130+
"tracker_story": "${{ steps.story-id.outputs.story_id }}"
131+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Update shared github-config
2+
3+
on:
4+
schedule:
5+
- cron: '10 9 * * *'
6+
workflow_dispatch: { }
7+
8+
jobs:
9+
build:
10+
name: Create PR to update shared files
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
18+
ref: master
19+
20+
- name: Checkout github-config
21+
uses: actions/checkout@v4
22+
with:
23+
repository: cloudfoundry/buildpacks-github-config
24+
path: github-config
25+
26+
- name: Checkout Branch
27+
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main
28+
with:
29+
branch: automation/github-config/update
30+
31+
- name: Run the sync action
32+
uses: paketo-buildpacks/github-config/actions/sync@main
33+
with:
34+
workspace: /github/workspace
35+
config: /github/workspace/github-config/buildpack
36+
37+
- name: Cleanup
38+
run: rm -rf github-config
39+
40+
- name: Commit
41+
id: commit
42+
uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main
43+
with:
44+
message: "Updating github-config"
45+
pathspec: "."
46+
committer_name: "Cloud Foundry Buildpacks Team Robot"
47+
committer_email: "cf-buildpacks-eng@pivotal.io"
48+
keyid: ${{ secrets.CF_BOT_GPG_KEY_ID }}
49+
key: ${{ secrets.CF_BOT_GPG_KEY }}
50+
51+
- name: Push Branch
52+
if: ${{ steps.commit.outputs.commit_sha != '' }}
53+
uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main
54+
with:
55+
branch: automation/github-config/update
56+
57+
- name: Open Pull Request
58+
if: ${{ steps.commit.outputs.commit_sha != '' }}
59+
uses: paketo-buildpacks/github-config/actions/pull-request/open@main
60+
with:
61+
token: ${{ secrets.CF_BOT_GITHUB_TOKEN }}
62+
title: "Updates github-config"
63+
branch: automation/github-config/update
64+
base: master

0 commit comments

Comments
 (0)