chore: update global workflows (#3536)
This commit is contained in:
192
.github/workflows/release-notifier.yml
vendored
192
.github/workflows/release-notifier.yml
vendored
@@ -3,7 +3,7 @@
|
|||||||
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
|
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
|
||||||
# the above-mentioned repo.
|
# the above-mentioned repo.
|
||||||
|
|
||||||
# Send release notification to various platforms.
|
# Create a blog post for a new release and open a PR to the blog repo
|
||||||
|
|
||||||
name: Release Notifications
|
name: Release Notifications
|
||||||
|
|
||||||
@@ -13,99 +13,115 @@ on:
|
|||||||
- released # this triggers when a release is published, but does not include pre-releases or drafts
|
- released # this triggers when a release is published, but does not include pre-releases or drafts
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
simplified_changelog:
|
update-blog:
|
||||||
if: >-
|
if: >-
|
||||||
startsWith(github.repository, 'LizardByte/') &&
|
github.repository_owner == 'LizardByte'
|
||||||
!github.event.release.prerelease &&
|
|
||||||
!github.event.release.draft
|
|
||||||
outputs:
|
|
||||||
SIMPLIFIED_BODY: ${{ steps.output.outputs.SIMPLIFIED_BODY }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: remove contributors section
|
- name: Check topics
|
||||||
env:
|
env:
|
||||||
RELEASE_BODY: ${{ github.event.release.body }}
|
TOPIC: replicator-release-notifications
|
||||||
id: output
|
id: check-label
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const topic = process.env.TOPIC;
|
||||||
|
console.log(`Checking if repo has topic: ${topic}`);
|
||||||
|
|
||||||
|
const repoTopics = await github.rest.repos.getAllTopics({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
});
|
||||||
|
console.log(`Repo topics: ${repoTopics.data.names}`);
|
||||||
|
|
||||||
|
const hasTopic = repoTopics.data.names.includes(topic);
|
||||||
|
console.log(`Has topic: ${hasTopic}`);
|
||||||
|
|
||||||
|
core.setOutput('hasTopic', hasTopic);
|
||||||
|
|
||||||
|
- name: Check if latest GitHub release
|
||||||
|
id: check-release
|
||||||
|
if: >-
|
||||||
|
steps.check-label.outputs.hasTopic == 'true'
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const latestRelease = await github.rest.repos.getLatestRelease({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo
|
||||||
|
});
|
||||||
|
|
||||||
|
core.setOutput('isLatestRelease', latestRelease.data.tag_name === context.payload.release.tag_name);
|
||||||
|
|
||||||
|
- name: Checkout blog
|
||||||
|
if: >-
|
||||||
|
steps.check-label.outputs.hasTopic == 'true' &&
|
||||||
|
steps.check-release.outputs.isLatestRelease == 'true'
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: "LizardByte/LizardByte.github.io"
|
||||||
|
|
||||||
|
- name: Create blog post
|
||||||
|
if: >-
|
||||||
|
steps.check-label.outputs.hasTopic == 'true' &&
|
||||||
|
steps.check-release.outputs.isLatestRelease == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo "${RELEASE_BODY}" > ./release_body.md
|
# setup variables
|
||||||
modified_body=$(sed '/^---/,$d' ./release_body.md)
|
tag_name="${{ github.event.release.tag_name }}"
|
||||||
echo "modified_body: ${modified_body}"
|
semver="${tag_name#v}"
|
||||||
|
repo_lower="$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
file_name="_posts/releases/${repo_lower}/${semver//./-}.md"
|
||||||
|
mkdir -p "$(dirname "${file_name}")"
|
||||||
|
|
||||||
# use a heredoc to ensure the output is multiline
|
# create jekyll blog post
|
||||||
echo "SIMPLIFIED_BODY<<EOF" >> $GITHUB_OUTPUT
|
echo "---" > "${file_name}"
|
||||||
echo "${modified_body}" >> $GITHUB_OUTPUT
|
echo "layout: release" >> "${file_name}"
|
||||||
echo "EOF" >> $GITHUB_OUTPUT
|
echo "title: ${{ github.event.repository.name }} ${tag_name} Released" >> "${file_name}"
|
||||||
|
echo "gh-repo: ${{ github.repository }}" >> "${file_name}"
|
||||||
|
echo "gh-badge: [follow, fork, star]" >> "${file_name}"
|
||||||
|
echo "tags: [release, ${repo_lower}]" >> "${file_name}"
|
||||||
|
echo "comments: true" >> "${file_name}"
|
||||||
|
echo "author: LizardByte-bot" >> "${file_name}"
|
||||||
|
echo "---" >> "${file_name}"
|
||||||
|
echo "" >> "${file_name}"
|
||||||
|
|
||||||
discord:
|
release_body=$(cat <<EOF
|
||||||
if: >-
|
${{ github.event.release.body }}
|
||||||
startsWith(github.repository, 'LizardByte/') &&
|
EOF
|
||||||
!github.event.release.prerelease &&
|
)
|
||||||
!github.event.release.draft
|
|
||||||
needs: simplified_changelog
|
echo "${release_body}" >> "${file_name}"
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
- name: Create/Update Pull Request
|
||||||
- name: discord
|
id: create-pr
|
||||||
uses: sarisia/actions-status-discord@v1
|
if: >-
|
||||||
|
steps.check-label.outputs.hasTopic == 'true' &&
|
||||||
|
steps.check-release.outputs.isLatestRelease == 'true'
|
||||||
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
avatar_url: ${{ secrets.ORG_LOGO_URL }}
|
token: ${{ secrets.GH_BOT_TOKEN }}
|
||||||
color: 0x00ff00
|
commit-message: |
|
||||||
description: ${{ needs.simplified_changelog.outputs.SIMPLIFIED_BODY }}
|
chore: Add blog post for ${{ github.event.repository.name }} release ${{ github.event.release.tag_name }}
|
||||||
nodetail: true
|
branch: bot/add-${{ github.event.repository.name }}-${{ github.event.release.tag_name }}
|
||||||
nofail: false
|
delete-branch: true
|
||||||
title: ${{ github.event.repository.name }} ${{ github.ref_name }} Released
|
title: |
|
||||||
url: ${{ github.event.release.html_url }}
|
chore: Add blog post for ${{ github.event.repository.name }} release ${{ github.event.release.tag_name }}
|
||||||
username: ${{ secrets.DISCORD_USERNAME }}
|
body: ${{ github.event.release.body }}
|
||||||
webhook: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
|
labels:
|
||||||
|
blog
|
||||||
|
|
||||||
facebook_page:
|
- name: Automerge PR
|
||||||
if: >-
|
env:
|
||||||
startsWith(github.repository, 'LizardByte/') &&
|
GH_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
|
||||||
!github.event.release.prerelease &&
|
if: >-
|
||||||
!github.event.release.draft
|
steps.check-label.outputs.hasTopic == 'true' &&
|
||||||
runs-on: ubuntu-latest
|
steps.check-release.outputs.isLatestRelease == 'true'
|
||||||
steps:
|
run: |
|
||||||
- name: facebook-post-action
|
gh \
|
||||||
uses: LizardByte/facebook-post-action@v2024.1207.15428
|
pr \
|
||||||
with:
|
merge \
|
||||||
page_id: ${{ secrets.FACEBOOK_PAGE_ID }}
|
--auto \
|
||||||
access_token: ${{ secrets.FACEBOOK_ACCESS_TOKEN }}
|
--delete-branch \
|
||||||
message: |
|
--repo "LizardByte/LizardByte.github.io" \
|
||||||
${{ github.event.repository.name }} ${{ github.ref_name }} Released
|
--squash \
|
||||||
url: ${{ github.event.release.html_url }}
|
"${{ steps.create-pr.outputs.pull-request-number }}"
|
||||||
|
|
||||||
reddit:
|
|
||||||
if: >-
|
|
||||||
startsWith(github.repository, 'LizardByte/') &&
|
|
||||||
!github.event.release.prerelease &&
|
|
||||||
!github.event.release.draft
|
|
||||||
needs: simplified_changelog
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: reddit
|
|
||||||
uses: bluwy/release-for-reddit-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.REDDIT_USERNAME }}
|
|
||||||
password: ${{ secrets.REDDIT_PASSWORD }}
|
|
||||||
app-id: ${{ secrets.REDDIT_CLIENT_ID }}
|
|
||||||
app-secret: ${{ secrets.REDDIT_CLIENT_SECRET }}
|
|
||||||
subreddit: ${{ secrets.REDDIT_SUBREDDIT }}
|
|
||||||
title: ${{ github.event.repository.name }} ${{ github.ref_name }} Released
|
|
||||||
url: ${{ github.event.release.html_url }}
|
|
||||||
flair-id: ${{ secrets.REDDIT_FLAIR_ID }} # https://www.reddit.com/r/<subreddit>>/api/link_flair.json
|
|
||||||
comment: ${{ needs.simplified_changelog.outputs.SIMPLIFIED_BODY }}
|
|
||||||
|
|
||||||
x:
|
|
||||||
if: >-
|
|
||||||
startsWith(github.repository, 'LizardByte/') &&
|
|
||||||
!github.event.release.prerelease &&
|
|
||||||
!github.event.release.draft
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: x
|
|
||||||
uses: nearform-actions/github-action-notify-twitter@v1
|
|
||||||
with:
|
|
||||||
message: ${{ github.event.release.html_url }}
|
|
||||||
twitter-app-key: ${{ secrets.X_APP_KEY }}
|
|
||||||
twitter-app-secret: ${{ secrets.X_APP_SECRET }}
|
|
||||||
twitter-access-token: ${{ secrets.X_ACCESS_TOKEN }}
|
|
||||||
twitter-access-token-secret: ${{ secrets.X_ACCESS_TOKEN_SECRET }}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user