Skip to content

Create the PR to draft branch for release blog post #67

Create the PR to draft branch for release blog post

Create the PR to draft branch for release blog post #67

name: Create the PR to `draft` 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
publish-date:
description: 'Blog post publish date, format: YYYY-MM-DD'
required: true
default: '2050-01-01'
type: string
author-name:
description: "Author's name"
required: true
# default: ${{ github.actor }}
type: string
github-username:
description: "Author's GitHub username"
required: true
# default: ${{ github.actor }}
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_draft_pr:
name: Automate release and beta blog PR creation for `draft` branch
runs-on: ubuntu-latest
steps:
- name: Checkout prod
uses: actions/checkout@v3
with:
ref: prod
- name: Create new branch ${{ inputs.version }}-post
if: false
run: git checkout -b ${{ inputs.version }}-post
- name: Create blog
run: |
python3 .github/workflows/gen_blog.py ${{ inputs.version }} ${{ inputs.publish-date }} "${{ inputs.author-name }}" ${{ inputs.github-username }}
- 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 ${{ inputs.publish-date }} | tr - /)/${{ inputs.version }}.html"
echo "::set-output name=staging-url::https://blogs-staging-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/$(echo ${{ inputs.publish-date }} | tr - /)/${{ inputs.version }}.html"
echo "::set-output name=pr-branch::Draft"
- name: Commit post and create PR to draft branch
id: create-pr
run: |
git config user.name github-actions
git config user.email [email protected]
git add -A
git commit -m ${{ inputs.version }} --author "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git push origin prod:${{ inputs.version }}-post
echo "::set-output name=pr-url::$(gh pr create --base draft --head ${{ inputs.version }}-post --title "${{ inputs.version }} draft" --assignee ${{ github.actor }} --body "After this PR is merged, preview at draft site:&nbsp;${{ steps.gen-url.outputs.draft-url }}")"
- name: Create PR using action from marketplace
if: false
id: create-pr-old
uses: peter-evans/create-pull-request@v4
with:
commit-message: ${{ inputs.version }}
branch: ${{ inputs.version }}-post
base: prod
title: ${{ inputs.version }} draft
assignees: ${{ github.actor }}
body: "After this PR is merged, preview at draft site: ${{ steps.gen-url.outputs.draft-url }}"
- name: Update PR to draft branch
if: false
run: gh pr edit ${{ steps.create-pr.outputs.pull-request-number }} --base draft
- name: Send Slack alert
run: |
python3 .github/workflows/slack_alert.py \
${{ inputs.version }} ${{ inputs.publish-date }} "${{ inputs.author-name }}" ${{ inputs.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.draft-url }}