Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Pipelines Workflow #19

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
codeowners:
- path: "*"
owner: "@paketo-buildpacks/java-buildpacks"
78 changes: 78 additions & 0 deletions .github/workflows/update-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Update Pipeline
"on":
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Pipeline
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- name: Install octo
run: |
#!/usr/bin/env bash

set -euo pipefail

GO111MODULE=on go get -u -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo
- id: pipeline
name: Update 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

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 "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${NEW_VERSION}"
echo "::set-output name=release-notes::${RELEASE_NOTES//$'\n'/%0A}"
env:
DESCRIPTOR: .github/pipeline-descriptor.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v3
with:
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.GITHUB_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/update-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Update Pipelines
"on":
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Pipelines
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.15"
- name: Install octo
run: |
#!/usr/bin/env bash

set -euo pipefail

GO111MODULE=on go get -u -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo
- id: pipelines
name: Update Pipelines
run: |
#!/usr/bin/env bash

set -euo pipefail

if [[ -f .github/pipelines-version ]]; then
OLD_VERSION=$(cat .github/pipelines-version)
else
OLD_VERSION="0.0.0"
fi

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/pipelines-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 "::set-output name=old-version::${OLD_VERSION}"
echo "::set-output name=new-version::${NEW_VERSION}"
echo "::set-output name=release-notes::${RELEASE_NOTES//$'\n'/%0A}"
env:
DESCRIPTOR: .github/pipelines-descriptor.yml
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v3
with:
body: |-
Bumps pipelines from `${{ steps.pipelines.outputs.old-version }}` to `${{ steps.pipelines.outputs.new-version }}`.

<details>
<summary>Release Notes</summary>
${{ steps.pipelines.outputs.release-notes }}
</details>
branch: update/pipelines
commit-message: |-
Bump pipelines from ${{ steps.pipelines.outputs.old-version }} to ${{ steps.pipelines.outputs.new-version }}

Bumps pipelines from ${{ steps.pipelines.outputs.old-version }} to ${{ steps.pipelines.outputs.new-version }}.
delete-branch: true
labels: semver:patch, type:task
signoff: true
title: Bump pipelines from ${{ steps.pipelines.outputs.old-version }} to ${{ steps.pipelines.outputs.new-version }}
token: ${{ secrets.GITHUB_TOKEN }}