-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add call to the new github action for setting chart version (my fork currently) * switch to my github actions branch * use issue title instead of name param * Squash of the commits for v2 of the release automation (original commit messages were... not good) * Remove unnecessary definitions * Fix release_body typo
- Loading branch information
Showing
6 changed files
with
119 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Creating a LodeStar Release | ||
about: A template to use for releasing | ||
title: v1.0.0 | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
This repository contains GitHub workflows for managing releases automatically. | ||
|
||
**Please name this issue what you would like the new release to be called. E.x. "v1.0.0"** | ||
|
||
The following slash commands are available to use in comments on this issue: | ||
|
||
| Command | Description | Parameters | | ||
|---|---|---| | ||
| `/release` | Creates a new released based on the current state of the `master` branch | `frontend=<version>`<br/>`backend=<version>`<br/>`gitapi=<version>`<br/>`dispatcher=<version>`<br/>`agnosticv=<version>`<br/>`anarchy=<version>`<br/>`poolboy=<version>` | | ||
| `/promote` | Promotes the created release to the next environment | N/A | | ||
| `/cancel` | Cancels the current release (closes this issue) | N/A | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Cancel Dispatch | ||
|
||
on: | ||
repository_dispatch: | ||
types: [cancel-command] | ||
jobs: | ||
promote-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set Env Variables | ||
id: env_info | ||
run: | | ||
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH) | ||
echo ::set-output name=requestor::$(jq .client_payload.github.actor $GITHUB_EVENT_PATH) | ||
- name: Close Issue | ||
uses: peter-evans/close-issue@v1 | ||
with: | ||
issue-number: ${{ steps.env_info.outputs.issuenm }} | ||
comment: Cancelling rollout as requested by ${{ steps.env_info.outputs.requestor }}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,25 +5,35 @@ on: | |
types: [promote-command] | ||
jobs: | ||
promote-release: | ||
if: ${{ github.event.client_payload.slash_command.env }} && ${{ github.event.client_payload.slash_command.name }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set Env Variables | ||
id: env_info | ||
run: | | ||
echo ::set-output name=issuetitle::$(jq -r .client_payload.github.payload.issue.title $GITHUB_EVENT_PATH) | ||
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH) | ||
echo ::set-output name=labels::$(jq .client_payload.github.payload.issue.labels $GITHUB_EVENT_PATH) | ||
echo ::set-output name=requestor::$(jq .client_payload.github.actor $GITHUB_EVENT_PATH) | ||
- name: Set New Env (Integration) | ||
if: ${{ !contains(steps.env_info.outputs.labels, 'promoted to integration') }} | ||
run: | | ||
echo ::set-env name=NEW_ENV::integration | ||
- name: Set New Env (Production) | ||
if: ${{ contains(steps.env_info.outputs.labels, 'promoted to integration') }} | ||
run: | | ||
echo ::set-env name=NEW_ENV::production | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.client_payload.slash_command.name }} | ||
ref: ${{ steps.env_info.outputs.issuetitle }} | ||
- name: GitHub Pull Request Action | ||
id: create_pr | ||
uses: repo-sync/[email protected] | ||
with: | ||
source_branch: ${{ github.event.client_payload.slash_command.name }} | ||
destination_branch: ${{ github.event.client_payload.slash_command.env }} | ||
source_branch: ${{ steps.env_info.outputs.issuetitle }} | ||
destination_branch: ${{ env.NEW_ENV }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
pr_title: "Promoting ${{ github.event.client_payload.slash_command.name }} to ${{ github.event.client_payload.slash_command.env }}" | ||
pr_body: "Promoting release ${{ github.event.client_payload.slash_command.name }} to the ${{ github.event.client_payload.slash_command.env }} environment as requested by @${{ steps.env_info.outputs.requestor }}." | ||
pr_title: "Promoting ${{ steps.env_info.outputs.issuetitle }} to ${{ env.NEW_ENV }}" | ||
pr_body: "Promoting release ${{ steps.env_info.outputs.issuetitle }} to the $NEW_ENV environment as requested by @${{ steps.env_info.outputs.requestor }}." | ||
- name: Get PR number | ||
id: pr_num | ||
run: | | ||
|
@@ -38,7 +48,7 @@ jobs: | |
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: ${{steps.pr_num.outputs.prnm}}, | ||
labels: ["${{github.event.client_payload.slash_command.name }}"] | ||
labels: ["${{ steps.env_info.outputs.issuetitle }}"] | ||
}) | ||
- name: Auto-merge | ||
uses: actions/github-script@v2 | ||
|
@@ -51,4 +61,22 @@ jobs: | |
pull_number: ${{ steps.pr_num.outputs.prnm}}, | ||
merge_method: "squash" | ||
}) | ||
- name: Apply label to issue | ||
uses: actions/github-script@v1 | ||
if: ${{ steps.create_label.outcome == 'success' }} | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
github.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: ${{steps.env_info.outputs.issuenm}}, | ||
labels: ["promoted to ${{ env.NEW_ENV }}"] | ||
}) | ||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
issue-number: "${{ steps.env_info.outputs.issuenm }}" | ||
body: | | ||
Promoted release ${{ steps.env_info.outputs.issuetitle }} to ${{ env.NEW_ENV }}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,25 @@ on: | |
types: [release-command] | ||
jobs: | ||
create-release-branch: | ||
if: ${{ github.event.client_payload.slash_command.name }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get Environment Info | ||
id: env_info | ||
run: | | ||
echo ::set-output name=release::$(git ls-remote --heads https://github.com/$GITHUB_REPOSITORY ${{ github.event.client_payload.slash_command.name }}) | ||
ISSUE_TITLE=$(jq -r .client_payload.github.payload.issue.title $GITHUB_EVENT_PATH) | ||
echo ::set-output name=release::$(git ls-remote --heads https://github.com/$GITHUB_REPOSITORY $ISSUE_TITLE) | ||
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH) | ||
echo ::set-output name=issuetitle::$ISSUE_TITLE | ||
- name: Create release branch | ||
uses: peterjgrainger/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
branch: ${{ github.event.client_payload.slash_command.name }} | ||
branch: "${{ steps.env_info.outputs.issuetitle }}" | ||
if: ${{ steps.env_info.outputs.release == null }} | ||
- name: Alert that release already exists | ||
run: | | ||
echo "Release branch ${{ github.event.client_payload.slash_command.name }} already exists. Skipping..." | ||
echo "Release branch ${{ steps.env_info.outputs.issuetitle }} already exists. Skipping..." | ||
if: ${{ steps.env_info.outputs.release != null }} | ||
- name: Check if label exists | ||
uses: actions/github-script@v1 | ||
|
@@ -34,7 +35,7 @@ jobs: | |
github.issues.getLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: "${{ github.event.client_payload.slash_command.name }}" | ||
name: "${{ steps.env_info.outputs.issuetitle }}" | ||
}) | ||
- name: Create label to be used for release | ||
uses: actions/github-script@v1 | ||
|
@@ -45,7 +46,7 @@ jobs: | |
github.issues.createLabel({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: "${{ github.event.client_payload.slash_command.name }}", | ||
name: "${{ steps.env_info.outputs.issuetitle }}", | ||
color: "2d5893" | ||
}) | ||
if: ${{ steps.label_check.outcome == 'failure' }} | ||
|
@@ -59,7 +60,7 @@ jobs: | |
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: ${{steps.env_info.outputs.issuenm}}, | ||
labels: ["${{github.event.client_payload.slash_command.name }}"] | ||
labels: ["${{ steps.env_info.outputs.issuetitle }}"] | ||
}) | ||
update-release-pointers: | ||
|
@@ -69,10 +70,12 @@ jobs: | |
- name: Get Environment Info | ||
id: env_info | ||
run: | | ||
echo ::set-output name=issuetitle::$(jq -r .client_payload.github.payload.issue.title $GITHUB_EVENT_PATH) | ||
echo ::set-output name=issuenm::$(jq .client_payload.github.payload.issue.number $GITHUB_EVENT_PATH) | ||
echo ::set-output name=comment_url::$(jq .client_payload.github.payload.comment.html_url $GITHUB_EVENT_PATH) | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.client_payload.slash_command.name }} | ||
ref: ${{ steps.env_info.outputs.issuetitle }} | ||
- name: Update Frontend Release | ||
if: ${{ github.event.client_payload.slash_command.frontend != null }} | ||
uses: mikefarah/[email protected] | ||
|
@@ -112,11 +115,35 @@ jobs: | |
uses: redhat-cop/github-actions/set-helm-version@master | ||
with: | ||
path: applications | ||
chart_version: ${{ github.event.client_payload.slash_command.name }} | ||
app_version: ${{ github.event.client_payload.slash_command.name }} | ||
chart_version: "${{ steps.env_info.outputs.issuetitle }}" | ||
app_version: "${{ steps.env_info.outputs.issuetitle }}" | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: ${{ github.event.client_payload.slash_command.name }} | ||
branch: "${{ steps.env_info.outputs.issuetitle }}" | ||
commit_message: "Merging changes requested from ${{ steps.env_info.outputs.comment_url }}" | ||
|
||
- name: 'Get Previous tag' | ||
id: previoustag | ||
uses: actions-ecosystem/action-get-latest-tag@v1 | ||
- name: Generate Release Body | ||
id: release_body | ||
run: | | ||
echo ::set-output name=text::$(git log ${{ steps.previoustag.outputs.tag }}..HEAD --pretty=format:"- %h %s by %an" --no-merges) | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | ||
with: | ||
tag_name: ${{ steps.env_info.outputs.issuetitle }} | ||
release_name: ${{ steps.env_info.outputs.issuetitle }} | ||
body: ${{ steps.release_body.outputs.text }} | ||
draft: false | ||
prerelease: false | ||
- name: Create comment | ||
uses: peter-evans/create-or-update-comment@v1 | ||
with: | ||
repository: ${{ github.event.client_payload.github.payload.repository.full_name }} | ||
issue-number: "${{ steps.env_info.outputs.issuenm }}" | ||
body: | | ||
Created release ${{ steps.env_info.outputs.issuetitle }}! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters