Skip to content

Create the PR to staging branch for release blog post #38

Create the PR to staging branch for release blog post

Create the PR to staging branch for release blog post #38

name: Create the PR to `staging` branch for release blog post
on:
workflow_dispatch:
inputs:
version:
description: 'Version of OpenLiberty to generate blog for, e.g. 22.0.0.9, 22.0.0.9-beta'
required: true
type: string
slack-notification:
description: 'Send Slack notification'
required: true
default: 'release channel'
type: choice
options:
- 'release channel'
- 'test channel'
- 'off'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create_blog_and_pr:
name: Automate release and beta blog PR creation for `staging` branch
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.version }}-post
- name: Get data from the draft post
id: get-draft-data
run: python3 .github/workflows/get_draft_blog_data.py ${{ inputs.version }}
- name: Generate draft and staging URLs
id: gen-url
run: |
echo "::set-output name=draft-url::https://blogs-draft-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/$(echo ${{ steps.get-draft-data.outputs.publish-date }} | tr - /)/${{ inputs.version }}.html"
echo "::set-output name=staging-url::https://blogs-staging-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/$(echo ${{ steps.get-draft-data.outputs.publish-date }} | tr - /)/${{ inputs.version }}.html"
echo "::set-output name=pr-branch::Staging"
- name: Create PR
id: create-pr
run: |
if [[ "${{ steps.get-draft-data.outputs.reviewers }}" != "" ]]; then
echo "The following reviewers will be assigned to the PR: ${{ steps.get-draft-data.outputs.reviewers }}"
echo "::set-output name=pr-url::$(gh pr create --base staging --head ${{ inputs.version }}-post --title "${{ inputs.version }} staging" --assignee ${{ github.actor }} --body "Preview at draft site:&nbsp;${{ steps.gen-url.outputs.draft-url }}<br><br>After this PR is merged, preview at staging site:&nbsp;${{ steps.gen-url.outputs.staging-url }}" --reviewer ${{ steps.get-draft-data.outputs.reviewers }})"
else
echo "No reviewers to assign to the PR"
echo "::set-output name=pr-url::$(gh pr create --base staging --head ${{ inputs.version }}-post --title "${{ inputs.version }} staging" --assignee ${{ github.actor }} --body "Preview at draft site:&nbsp;${{ steps.gen-url.outputs.draft-url }}<br><br>After this PR is merged, preview at staging site:&nbsp;${{ steps.gen-url.outputs.staging-url }}")"
fi
- name: Create PR Old
if: false
id: create-pr-old
uses: peter-evans/create-pull-request@v4
with:
commit-message: ${{ inputs.version }}
branch: ${{ inputs.version }}-post
base: staging
title: ${{ inputs.version }} staging
assignees: ${{ github.actor }}
body: "Preview at draft site: ${{ steps.gen-url.outputs.draft-url }}\nAfter this PR is merged, preview at staging site: ${{ steps.gen-url.outputs.staging-url }}"
reviewers: ${{ steps.get-draft-data.outputs.reviewers }}
- name: Send Slack alert
run: |
python3 .github/workflows/slack_alert.py \
${{ inputs.version }} ${{ steps.get-draft-data.outputs.publish-date }} "${{ steps.get-draft-data.outputs.author-name }}" ${{ steps.get-draft-data.outputs.github-username }} "${{ inputs.slack-notification }}" \
${{ secrets.SLACK_HOOK }} ${{ secrets.SLACK_HOOK_TEST }} \
${{ steps.create-pr.outputs.pr-url}} ${{ steps.gen-url.outputs.pr-branch }} ${{ steps.gen-url.outputs.staging-url }}