Skip to content

Commit

Permalink
Add Github Actions pipelines
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Mikusa <dan@mikusa.com>
  • Loading branch information
dmikusa committed Jul 31, 2023
1 parent ec292a0 commit 71a8c8c
Show file tree
Hide file tree
Showing 12 changed files with 368 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @paketo-buildpacks/java-maintainers
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
ignore:
- dependency-name: github.com/onsi/gomega
labels:
- semver:patch
- type:dependency-upgrade
42 changes: 42 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
- name: semver:major
description: A change requiring a major version bump
color: f9d0c4
- name: semver:minor
description: A change requiring a minor version bump
color: f9d0c4
- name: semver:patch
description: A change requiring a patch version bump
color: f9d0c4
- name: type:bug
description: A general bug
color: e3d9fc
- name: type:dependency-upgrade
description: A dependency upgrade
color: e3d9fc
- name: type:documentation
description: A documentation update
color: e3d9fc
- name: type:enhancement
description: A general enhancement
color: e3d9fc
- name: type:question
description: A user question
color: e3d9fc
- name: type:task
description: A general task
color: e3d9fc
- name: type:informational
description: Provides information or notice to the community
color: e3d9fc
- name: type:poll
description: Request for feedback from the community
color: e3d9fc
- name: note:ideal-for-contribution
description: An issue that a contributor can help us with
color: 54f7a8
- name: note:on-hold
description: We can't start working on this issue yet
color: 54f7a8
- name: note:good-first-issue
description: A good first issue to get started with
color: 54f7a8
7 changes: 7 additions & 0 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github:
username: ${{ secrets.JAVA_GITHUB_USERNAME }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

codeowners:
- path: "*"
owner: "@paketo-buildpacks/java-maintainers"
1 change: 1 addition & 0 deletions .github/pipeline-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.32.0
32 changes: 32 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
template: $CHANGES
name-template: $RESOLVED_VERSION
tag-template: v$RESOLVED_VERSION
categories:
- title: ⭐️ Enhancements
labels:
- type:enhancement
- title: "\U0001F41E Bug Fixes"
labels:
- type:bug
- title: "\U0001F4D4 Documentation"
labels:
- type:documentation
- title: ⛏ Dependency Upgrades
labels:
- type:dependency-upgrade
- title: "\U0001F6A7 Tasks"
labels:
- type:task
exclude-labels:
- type:question
version-resolver:
major:
labels:
- semver:major
minor:
labels:
- semver:minor
patch:
labels:
- semver:patch
default: patch
29 changes: 29 additions & 0 deletions .github/workflows/pb-minimal-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Minimal Labels
"on":
pull_request:
types:
- synchronize
- reopened
- labeled
- unlabeled
jobs:
semver:
name: Minimal Semver Labels
runs-on:
- ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v4
with:
count: 1
labels: semver:major, semver:minor, semver:patch
mode: exactly
type:
name: Minimal Type Labels
runs-on:
- ubuntu-latest
steps:
- uses: mheap/github-action-required-labels@v4
with:
count: 1
labels: type:bug, type:dependency-upgrade, type:documentation, type:enhancement, type:question, type:task
mode: exactly
17 changes: 17 additions & 0 deletions .github/workflows/pb-synchronize-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Synchronize Labels
"on":
push:
branches:
- main
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: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions .github/workflows/pb-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Tests
"on":
merge_group:
types:
- checks_requested
branches:
- main
pull_request: {}
push:
branches:
- main
jobs:
unit:
name: Unit Test
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
path: ${{ env.HOME }}/go/pkg/mod
restore-keys: ${{ runner.os }}-go-
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Install richgo
run: |
#!/usr/bin/env bash
set -euo pipefail
echo "Installing richgo ${RICHGO_VERSION}"
mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"
curl \
--location \
--show-error \
--silent \
"https://github.com/kyoh86/richgo/releases/download/v${RICHGO_VERSION}/richgo_${RICHGO_VERSION}_linux_amd64.tar.gz" \
| tar -C "${HOME}"/bin -xz richgo
env:
RICHGO_VERSION: 0.3.10
- name: Run Tests
run: |
#!/usr/bin/env bash
set -euo pipefail
richgo test ./...
env:
RICHGO_FORCE_COLOR: "1"
15 changes: 15 additions & 0 deletions .github/workflows/pb-update-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Update Draft Release
"on":
push:
branches:
- main
jobs:
update:
name: Update Draft Release
runs-on:
- ubuntu-latest
steps:
- id: release-drafter
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
72 changes: 72 additions & 0 deletions .github/workflows/pb-update-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Update Go
"on":
schedule:
- cron: 57 2 * * 1
workflow_dispatch: {}
jobs:
update:
name: Update Go
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- uses: actions/checkout@v3
- name: Update Go Version & Modules
id: update-go
run: |
#!/usr/bin/env bash
set -euo pipefail
if [ -z "${GO_VERSION:-}" ]; then
echo "No go version set"
exit 1
fi
OLD_GO_VERSION=$(grep -P '^go \d\.\d+' go.mod | cut -d ' ' -f 2)
go mod edit -go="$GO_VERSION"
go mod tidy
go get -u -t ./...
go mod tidy
git add go.mod go.sum
git checkout -- .
if [ "$OLD_GO_VERSION" == "$GO_VERSION" ]; then
COMMIT_TITLE="Bump Go Modules"
COMMIT_BODY="Bumps Go modules used by the project. See the commit for details on what modules were updated."
COMMIT_SEMVER="semver:patch"
else
COMMIT_TITLE="Bump Go from ${OLD_GO_VERSION} to ${GO_VERSION}"
COMMIT_BODY="Bumps Go from ${OLD_GO_VERSION} to ${GO_VERSION} and update Go modules used by the project. See the commit for details on what modules were updated."
COMMIT_SEMVER="semver:minor"
fi
echo "commit-title=${COMMIT_TITLE}" >> "$GITHUB_OUTPUT"
echo "commit-body=${COMMIT_BODY}" >> "$GITHUB_OUTPUT"
echo "commit-semver=${COMMIT_SEMVER}" >> "$GITHUB_OUTPUT"
env:
GO_VERSION: "1.20"
- uses: peter-evans/create-pull-request@v5
with:
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com>
body: |-
${{ steps.update-go.outputs.commit-body }}
<details>
<summary>Release Notes</summary>
${{ steps.pipeline.outputs.release-notes }}
</details>
branch: update/go
commit-message: |-
${{ steps.update-go.outputs.commit-title }}
${{ steps.update-go.outputs.commit-body }}
delete-branch: true
labels: ${{ steps.update-go.outputs.commit-semver }}, type:task
signoff: true
title: ${{ steps.update-go.outputs.commit-title }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
87 changes: 87 additions & 0 deletions .github/workflows/pb-update-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Update Pipeline
"on":
push:
branches:
- main
paths:
- .github/pipeline-descriptor.yml
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Pipeline
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.20"
- name: Install octo
run: |
#!/usr/bin/env bash
set -euo pipefail
go install -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo@latest
- uses: actions/checkout@v3
- name: Update Pipeline
id: pipeline
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ -f .github/pipeline-version ]]; then
OLD_VERSION=$(cat .github/pipeline-version)
else
OLD_VERSION="0.0.0"
fi
rm .github/workflows/pb-*.yml || true
octo --descriptor "${DESCRIPTOR}"
PAYLOAD=$(gh api /repos/paketo-buildpacks/pipeline-builder/releases/latest)
NEW_VERSION=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.name')
echo "${NEW_VERSION}" > .github/pipeline-version
RELEASE_NOTES=$(
gh api \
-F text="$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.body')" \
-F mode="gfm" \
-F context="paketo-buildpacks/pipeline-builder" \
-X POST /markdown
)
git add .github/
git checkout -- .
echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT"
echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
DELIMITER=$(openssl rand -hex 16) # roughly the same entropy as uuid v4 used in https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/core/src/file-command.ts#L28
printf "release-notes<<%s\n%s\n%s\n" "${DELIMITER}" "${RELEASE_NOTES}" "${DELIMITER}" >> "${GITHUB_OUTPUT}" # see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
env:
DESCRIPTOR: .github/pipeline-descriptor.yml
GITHUB_TOKEN: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v5
with:
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com>
body: |-
Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`.
<details>
<summary>Release Notes</summary>
${{ steps.pipeline.outputs.release-notes }}
</details>
branch: update/pipeline
commit-message: |-
Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
Bumps pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}.
delete-branch: true
labels: semver:patch, type:task
signoff: true
title: Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

0 comments on commit 71a8c8c

Please sign in to comment.