Skip to content

Commit

Permalink
feat(actions): Introduce prepare-release action (#5551)
Browse files Browse the repository at this point in the history
This action will create the daily next -> prod Novu Cloud release PR and print the commit log in Slack
  • Loading branch information
SokratisVidros committed May 14, 2024
1 parent 261c42e commit 37052c3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@
"unpublish",
"decompile",
"servername",
"neom"
"neom",
"automerge"
],
"flagWords": [],
"patterns": [
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/prepare-cloud-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Prepare Cloud Release"

on:
workflow_dispatch:
# Triggers the workflow every work day at 8:00 UTC
# The 3 hour offset should change when daylight savings change for GMT +3.
schedule:
- cron: "0 9 * * 1,2,3,4,5"

jobs:
prepare-cloud-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set output variables
id: output-variables
run: |
echo "date_humanized=$(date +'%Y-%m-%d %H:%M')" >> "$GITHUB_OUTPUT"
echo "branch_name=release_$(date +'%Y_%m_%d_%H_%M')" >> "$GITHUB_OUTPUT"
- name: Create Novu Cloud release branch
run: git checkout -b ${{ steps.output-variables.outputs.branch_name }}

- name: Push release branch
run: git push origin ${{ steps.output-variables.outputs.branch_name }}

- name: Create Novu Cloud release PR
id: create-pr
run: |
echo "pr_url=$(gh pr create --base prod --head ${{steps.output-variables.outputs.branch_name}} --title 'Release ${{steps.output-variables.outputs.date_humanized}}' --body 'Automated daily production Novu Cloud release')" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Enable PR automerge
id: enable-pr-automerge
run: |
gh pr merge --auto -r ${{steps.create-pr.outputs.pr_url}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Generate commit log
id: commit-log
run: |
echo 'COMMIT_LOG<<EOF' >> $GITHUB_ENV
echo $(git log --format="format:%h %s (@%aL)\n" origin/prod..origin/${{steps.output-variables.outputs.branch_name}} | sed "s/\"/'/g") >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Send commit log to Slack
id: slack
uses: slackapi/[email protected]
with:
payload: |
{
"text": "*<${{steps.create-pr.outputs.pr_url}}|Novu Cloud Release: ${{steps.output-variables.outputs.date_humanized }}>*\n```${{env.COMMIT_LOG}}```",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<${{steps.create-pr.outputs.pr_url}}|Novu Cloud Release: ${{steps.output-variables.outputs.date_humanized }}>*\n```${{env.COMMIT_LOG}}```"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL_ENG_FEED_DEPLOYMENTS}}

0 comments on commit 37052c3

Please sign in to comment.