I'm currently using the Release Drafter workflow that creates a draft release whenever a PR is merged into the develop branch (staging). This creates a great draft but now I'm wanting to have it get published when develop is merged into master. When that takes place I need to update the release name and tag before publishing. Then send out a notification in our slack engineering channel.
What I can do:
- Setup the action on push into master.
- Get the latest draft release and then use that id as a ref.
- Publish using eregon/publish-release action.
- Send the slack message
What I missing:
- An Action that I can pass the release id and update the tag and name.
The name and tag will be the current date %Y.%m%.d-%H:%M
Here is the action YML I have created so far
name: On master merged publish release & notify
on:
push:
branches:
- "master"
jobs:
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create tag from date
id: create_tag
run: |
tag=builds-$(date +%Y.%m%.d__%H:%M)
echo "::set-output name=tag::$tag" # https://github.com/ruby/ruby-dev-builder/blob/master/.github/workflows/build.yml
- name: Get last Draft
id: last_release
uses: InsonusK/get-latest-release@v1.0.1 # https://github.com/InsonusK/get-latest-release
with:
myToken: ${{ github.token }} # TODO check if set
exclude_types: "release"
view_top: 1
- name: "Print result"
run: |
echo "id: ${{ steps.last_release.outputs.id }}"
echo "name: ${{ steps.last_release.outputs.name }}"
echo "tag_name: ${{ steps.last_release.outputs.tag_name }}"
echo "created_at: ${{ steps.last_release.outputs.created_atd }}"
echo "draft: ${{ steps.last_release.outputs.draft }}"
echo "prerelease: ${{ steps.last_release.outputs.prerelease }}"
# This is Pseudocode.
- name: update release
id: update_release
uses: tubone24/update_release@v1.0
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag: ${{ steps.create_tag.outputs.tag }}
- name: Publish Release
- uses: eregon/publish-release@v1 #https://github.com/elgohr/Github-Release-Action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.last_release.outputs.release_id }}
# Needs test
- name: Slack Notification Success
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: automated-deploys
SLACK_COLOR: green
SLACK_MESSAGE: ${{ steps.last_release.outputs.body }} # TODO get info
SLACK_TITLE: Deploying
SLACK_USERNAME: GH Action Parrot
SLACK_ICON: https://emoji.slack-edge.com/T3LPQHAMV/headbangingparrot/1898efdc354c8ff8.gif
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}