-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into repo-refresh
- Loading branch information
Showing
3 changed files
with
59 additions
and
10 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,15 @@ | ||
### Deployment Results {{ ":white_check_mark:" if status === "success" else ":x:" }} | ||
|
||
{% if status === "success" %} **{{ actor }}** successfully **{{ "noop" if noop else "branch" }}** deployed branch `{{ ref }}` to **{{ environment }}**{% endif %} | ||
|
||
{% if status === "failure" %} **{{ actor }}** your **{{ "noop" if noop else "branch" }}** deployment of `{{ ref }}` failed to deploy to the **{{ environment }}** environment{% endif %} | ||
|
||
{% if status === "unknown" %} **{{ actor }}** your **{{ "noop" if noop else "branch" }}** deployment of `{{ ref }}` is in an unknown state when trying to deploy to the **{{ environment }}** environment.{% endif %} | ||
|
||
<details><summary>Show Results</summary> | ||
|
||
```text | ||
<%= results %> | ||
``` | ||
|
||
</details> |
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 |
---|---|---|
|
@@ -4,28 +4,48 @@ on: | |
issue_comment: | ||
types: [created] | ||
|
||
permissions: write-all | ||
# Permissions needed for reacting and adding comments for IssueOps commands | ||
permissions: | ||
pull-requests: write | ||
deployments: write | ||
contents: write | ||
checks: read | ||
|
||
jobs: | ||
rubocop: | ||
name: runner / rspec | ||
branch-deploy: | ||
name: branch-deploy | ||
if: # only run on pull request comments and very specific comment body string as defined in our branch-deploy settings | ||
${{ github.event.issue.pull_request && | ||
(startsWith(github.event.comment.body, '.deploy') || | ||
startsWith(github.event.comment.body, '.noop') || | ||
startsWith(github.event.comment.body, '.lock') || | ||
startsWith(github.event.comment.body, '.help') || | ||
startsWith(github.event.comment.body, '.wcid') || | ||
startsWith(github.event.comment.body, '.unlock')) }} | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: branch-deploy | ||
id: branch-deploy | ||
uses: github/branch-deploy@fb5baec9eccc077f582d8850521b8bc3043f550f # [email protected] | ||
uses: github/branch-deploy@v9 | ||
with: | ||
trigger: ".deploy" | ||
environment: "production" | ||
sticky_locks: "true" # https://github.com/github/branch-deploy/blob/1f6516ef5092890ce75d9e97ca7cbdb628e38bdd/docs/hubot-style-deployment-locks.md | ||
|
||
# Check out the ref from the output of the IssueOps command | ||
- uses: actions/checkout@v4 | ||
if: ${{ steps.branch-deploy.outputs.continue == 'true' }} | ||
with: | ||
ref: ${{ steps.branch-deploy.outputs.ref }} | ||
|
||
- uses: ruby/setup-ruby@d4526a55538b775af234ba4af27118ed6f8f6677 # [email protected] | ||
- uses: ruby/setup-ruby@cd4241788aec4fdcd3325da7068efa9b62a017af | ||
if: ${{ steps.branch-deploy.outputs.continue == 'true' }} | ||
with: | ||
bundler-cache: true | ||
|
||
- name: bootstrap | ||
if: ${{ steps.branch-deploy.outputs.continue == 'true' }} | ||
run: script/bootstrap | ||
|
||
# Here we run a deploy. It is "gated" by the IssueOps logic and will only run if the outputs from our branch-deploy step indicate that the workflow should continue | ||
|
@@ -34,8 +54,5 @@ jobs: | |
run: | | ||
set -o pipefail | ||
script/deploy | tee deploy.out | ||
MSG=$(cat deploy.out) | ||
MSG="\`\`\`output\n${MSG}\n\`\`\`" | ||
echo 'DEPLOY_MESSAGE<<EOF' >> $GITHUB_ENV | ||
echo "$MSG" >> $GITHUB_ENV | ||
echo 'EOF' >> $GITHUB_ENV | ||
bundle exec ruby script/ci/render_deploy_message.rb | ||
rm deploy.out |
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,17 @@ | ||
# frozen_string_literal: true | ||
require "erb" | ||
|
||
# load the output file | ||
input_file_path = ENV.fetch("INPUT_FILE_PATH", "deploy.out") | ||
puts "reading deployment output from: #{input_file_path}" | ||
results = File.read(input_file_path) | ||
|
||
erb_template = ENV.fetch("TEMPLATE", ".github/deployment_message.md") | ||
template = ERB.new(File.read(erb_template)) | ||
# render the ERB template with binding on <%= results %> to replace it with the results | ||
erb_template_rendered = template.result(binding) | ||
|
||
template_save_path = ENV.fetch("TEMPLATE_SAVE_PATH", erb_template) | ||
puts "saving the rendered ERB template to: #{template_save_path}" | ||
|
||
File.open(template_save_path, "w") { |file| file.write(erb_template_rendered) } |