Create the PR to draft branch for release blog post
#117
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Import GPG key | |
| run: | | |
| echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch | |
| git config --global user.signingkey ${{ secrets.GPG_KEY_ID }} | |
| git config --global commit.gpgsign true | |
| - 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 "draft-url=https://blogs-draft-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/$(echo ${{ inputs.publish-date }} | tr - /)/${{ inputs.version }}.html" >> $GITHUB_OUTPUT | |
| echo "staging-url=https://blogs-staging-openlibertyio.mqj6zf7jocq.us-south.codeengine.appdomain.cloud/blog/$(echo ${{ inputs.publish-date }} | tr - /)/${{ inputs.version }}.html" >> $GITHUB_OUTPUT | |
| echo "pr-branch=Draft" >> $GITHUB_OUTPUT | |
| - name: Commit post and create PR to draft branch | |
| id: create-pr | |
| run: | | |
| git config user.name github-actions | |
| git config user.email github-actions@github.com | |
| git config commit.gpgsign true | |
| git add -A | |
| git commit -S -m ${{ inputs.version }} --author "${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>" | |
| git push origin prod:${{ inputs.version }}-post | |
| echo "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 }}")" >> $GITHUB_OUTPUT | |
| - 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: Install Asciidoctor | |
| run: sudo apt-get install -y asciidoctor | |
| - name: Run Vale on AsciiDoc files | |
| uses: errata-ai/vale-action@v2.1.1 | |
| with: | |
| files: posts/${{ inputs.publish-date }}-${{ inputs.version }}.adoc | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| - 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 }} |