Merge pull request #12172 from bbc/WSTEAMA-1444-remove-election-banne… #1136
This file contains 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
## | |
# Review permissions available to this workflow before modifying it: https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28#repository-permissions-for-contents | |
## | |
name: Simorgh CI - Automatic Release | |
on: | |
push: | |
branches: | |
- latest | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
env: | |
CI: true | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: '0' | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Get New Release TagName | |
id: newReleaseTagName | |
run: | | |
JSON_RESPONSE=$(curl \ | |
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
-H 'Accept: application/vnd.github+json' \ | |
-H 'X-GitHub-Api-Version: 2022-11-28' \ | |
https://api.github.com/repos/${{ github.repository }}/releases/latest \ | |
--fail \ | |
| jq -r '.tag_name' \ | |
| awk 'BEGIN{FS=OFS="."} {$2+=1} 1') | |
echo $JSON_RESPONSE | |
echo "NEW_RELEASE_TAG_NAME=$JSON_RESPONSE" >> $GITHUB_OUTPUT | |
- name: Get New Release Commit Message | |
id: newReleaseMessage | |
run: | | |
NEW_RELEASE_MESSSAGE=$(curl \ | |
-H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ | |
-H 'Accept: application/vnd.github+json' \ | |
-H 'X-GitHub-Api-Version: 2022-11-28' \ | |
https://api.github.com/repos/${{ github.repository }}/commits/latest \ | |
--fail \ | |
| jq -r '.commit.message' \ | |
| sed 's/#[0-9]\{1,\}/\<a href="https:\/\/github.com\/bbc\/simorgh\/pull\/&\"\>&\<\/a\>/' \ | |
| sed 's/pull\/\#\{1,\}/pull\//' \ | |
| sed -e 's/"/\\"/g' -e 's/$/<br>/g' -e "s/'/%27/g" \ | |
| tr '\n' ' ' \ | |
| tr '\r' ' ' \ | |
) | |
echo $NEW_RELEASE_MESSSAGE | |
echo "NEW_RELEASE_MESSSAGE=$NEW_RELEASE_MESSSAGE" >> $GITHUB_OUTPUT | |
- name: Publish | |
run: | | |
curl \ | |
-X POST \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/${{ github.repository }}/releases \ | |
-d '{ | |
"tag_name": "${{ steps.newReleaseTagName.outputs.NEW_RELEASE_TAG_NAME }}", | |
"target_commitish": "latest", | |
"name": "Release ${{ steps.newReleaseTagName.outputs.NEW_RELEASE_TAG_NAME }}", | |
"body": "${{ steps.newReleaseMessage.outputs.NEW_RELEASE_MESSSAGE }}", | |
"draft": false, | |
"prerelease": false, | |
"generate_release_notes": false | |
}' \ | |
--fail |