-
Notifications
You must be signed in to change notification settings - Fork 72
92 lines (84 loc) · 3.79 KB
/
make_blog_draft_pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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: ${{ 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 }}