Skip to content

Commit 3555a68

Browse files
paketo-botForestEckhardt
authored andcommitted
Updating github-config
1 parent b1f6cf9 commit 3555a68

6 files changed

Lines changed: 264 additions & 1 deletion

File tree

.github/labels.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@
2828
- name: good first issue
2929
description: A good first issue to get started with
3030
color: d3fc03
31+
- name: "failure:release"
32+
description: An issue filed automatically when a release workflow run fails
33+
color: f00a0a
34+
- name: "failure:push"
35+
description: An issue filed automatically when a push buildpackage workflow run fails
36+
color: f00a0a
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Approve Bot PRs and Enable Auto-Merge
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Test Pull Request"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
download:
11+
name: Download PR Artifact
12+
if: ${{ github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' }}
13+
runs-on: ubuntu-latest
14+
outputs:
15+
pr-author: ${{ steps.pr-data.outputs.author }}
16+
pr-number: ${{ steps.pr-data.outputs.number }}
17+
steps:
18+
- name: 'Download artifact'
19+
uses: paketo-buildpacks/github-config/actions/pull-request/download-artifact@main
20+
with:
21+
name: "event-payload"
22+
repo: ${{ github.repository }}
23+
run_id: ${{ github.event.workflow_run.id }}
24+
workspace: "/github/workspace"
25+
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
26+
- id: pr-data
27+
run: |
28+
echo "::set-output name=author::$(jq -r '.pull_request.user.login' event.json)"
29+
echo "::set-output name=number::$(jq -r '.pull_request.number' event.json)"
30+
31+
approve:
32+
name: Approve Bot PRs
33+
needs: download
34+
if: ${{ needs.download.outputs.pr-author == 'paketo-bot' || needs.download.outputs.pr-author == 'dependabot[bot]' }}
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Check Commit Verification
38+
id: unverified-commits
39+
uses: paketo-buildpacks/github-config/actions/pull-request/check-unverified-commits@main
40+
with:
41+
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
42+
repo: ${{ github.repository }}
43+
number: ${{ needs.download.outputs.pr-number }}
44+
45+
- name: Check for Human Commits
46+
id: human-commits
47+
uses: paketo-buildpacks/github-config/actions/pull-request/check-human-commits@main
48+
with:
49+
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
50+
repo: ${{ github.repository }}
51+
number: ${{ needs.download.outputs.pr-number }}
52+
53+
- name: Checkout
54+
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
55+
uses: actions/checkout@v3
56+
57+
- name: Approve
58+
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
59+
uses: paketo-buildpacks/github-config/actions/pull-request/approve@main
60+
with:
61+
token: ${{ secrets.PAKETO_BOT_REVIEWER_GITHUB_TOKEN }}
62+
number: ${{ needs.download.outputs.pr-number }}
63+
64+
- name: Enable Auto-Merge
65+
if: steps.human-commits.outputs.human_commits == 'false' && steps.unverified-commits.outputs.unverified_commits == 'false'
66+
run: |
67+
gh pr merge ${{ needs.download.outputs.pr-number }} --auto --rebase
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: release
9+
10+
jobs:
11+
smoke:
12+
name: Smoke Test
13+
runs-on: ubuntu-latest
14+
outputs:
15+
release_notes: ${{ steps.notes.outputs.body }}
16+
steps:
17+
- name: Setup Go
18+
uses: actions/setup-go@v3
19+
with:
20+
go-version: 1.18.x
21+
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Get pack version
26+
id: pack-version
27+
run: |
28+
version=$(jq -r .pack "scripts/.util/tools.json")
29+
echo "::set-output name=version::${version#v}"
30+
31+
- name: Install Global Pack
32+
uses: buildpacks/github-actions/setup-pack@main
33+
with:
34+
pack-version: ${{ steps.pack-version.outputs.version }}
35+
36+
- name: Run Smoke Tests
37+
run: ./scripts/smoke.sh --name builder
38+
39+
- name: Generate Release Notes
40+
id: notes
41+
run: |
42+
notes="$(pack inspect-builder builder | grep -v 'Inspecting builder' \
43+
| grep -v 'REMOTE:' \
44+
| grep -v 'LOCAL:' \
45+
| grep -v '\(not present\)' \
46+
| grep -v 'Warning' \
47+
| sed -e '/./,$!d' \
48+
| awk -F, '{printf "%s\\n", $0}')"
49+
echo "::set-output name=body::${notes}"
50+
51+
release:
52+
name: Release
53+
runs-on: ubuntu-latest
54+
needs: smoke
55+
steps:
56+
- name: Checkout With History
57+
uses: actions/checkout/@v2
58+
with:
59+
fetch-depth: 0 # gets full history
60+
61+
- name: Compare With Previous Release
62+
id: compare_previous_release
63+
run: |
64+
if [ -z "$(git diff $(git describe --tags --abbrev=0) -- builder.toml)" ]
65+
then
66+
echo "::set-output name=builder_changes::false"
67+
else
68+
echo "::set-output name=builder_changes::true"
69+
fi
70+
71+
- name: Publish Release
72+
id: publish
73+
if: ${{ steps.compare_previous_release.outputs.builder_changes == 'true' }}
74+
uses: release-drafter/release-drafter@v5
75+
with:
76+
config-name: release-drafter-config.yml
77+
publish: true
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
80+
81+
- name: Update Release Notes
82+
if: ${{ steps.compare_previous_release.outputs.builder_changes == 'true' }}
83+
run: |
84+
set -e
85+
payload="{\"body\" : \"\`\`\`\n${RELEASE_BODY}\n\`\`\`\"}"
86+
87+
curl --fail \
88+
-X PATCH \
89+
-H "Accept: application/vnd.github.v3+json" \
90+
-H "Authorization: token ${GITHUB_TOKEN}" \
91+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
92+
-d "${payload}"
93+
env:
94+
RELEASE_ID: ${{ steps.publish.outputs.id }}
95+
RELEASE_BODY: ${{ needs.smoke.outputs.release_notes }}
96+
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
97+
98+
failure:
99+
name: Alert on Failure
100+
runs-on: ubuntu-latest
101+
needs: [ smoke, release ]
102+
if: ${{ always() && needs.smoke.result == 'failure' || needs.release.result == 'failure' }}
103+
steps:
104+
- name: File Failure Alert Issue
105+
uses: paketo-buildpacks/github-config/actions/issue/file@main
106+
with:
107+
token: ${{ secrets.GITHUB_TOKEN }}
108+
repo: ${{ github.repository }}
109+
label: "failure:release"
110+
comment_if_exists: true
111+
issue_title: "Failure: Create Release workflow"
112+
issue_body: |
113+
Create Release workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
114+
comment_body: |
115+
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}

.github/workflows/push-image.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Push Builder Image
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
push:
10+
name: Push
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- name: Parse Event
15+
id: event
16+
run: |
17+
echo "::set-output name=tag::$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)"
18+
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Get pack version
23+
id: pack-version
24+
run: |
25+
version=$(jq -r .pack "scripts/.util/tools.json")
26+
echo "::set-output name=version::${version#v}"
27+
28+
- name: Install Global Pack
29+
uses: buildpacks/github-actions/setup-pack@main
30+
with:
31+
pack-version: ${{ steps.pack-version.outputs.version }}
32+
33+
- name: Create Builder Image
34+
run: |
35+
pack builder create builder --config builder.toml
36+
37+
- name: Push To Dockerhub
38+
env:
39+
PAKETO_BUILDPACKS_DOCKERHUB_USERNAME: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}
40+
PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }}
41+
DOCKERHUB_ORG: "paketobuildpacks"
42+
run: |
43+
# Strip off the Github org prefix from repo name
44+
# paketo-buildpacks/builder-with-some-name --> builder-with-some-name
45+
registry_repo=$(echo "${{ github.repository }}" | sed 's/^.*\///')
46+
47+
echo "${PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD}" | docker login --username "${PAKETO_BUILDPACKS_DOCKERHUB_USERNAME}" --password-stdin
48+
docker tag builder "${DOCKERHUB_ORG}/${registry_repo}:latest"
49+
docker tag builder "${DOCKERHUB_ORG}/${registry_repo}:${{ steps.event.outputs.tag }}"
50+
51+
docker push "${DOCKERHUB_ORG}/${registry_repo}:latest"
52+
docker push "${DOCKERHUB_ORG}/${registry_repo}:${{ steps.event.outputs.tag }}"

.github/workflows/test-builder.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Test Builder
2+
3+
on:
4+
workflow_dispatch: {}
5+
6+
jobs:
7+
8+
smoke:
9+
name: Smoke Test
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Setup Go
13+
uses: actions/setup-go@v3
14+
with:
15+
go-version: 1.18.x
16+
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Run Smoke Tests
21+
run: ./scripts/smoke.sh

scripts/.util/tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"pack": "v0.26.0"
2+
"pack": "v0.27.0"
33
}

0 commit comments

Comments
 (0)