Create PR from Action

This commit is contained in:
Sergio Padrino 2022-06-14 18:27:59 +02:00
parent 704e279a60
commit 3aeb375be5
2 changed files with 97 additions and 0 deletions

48
.github/workflows/release-pr.yml vendored Normal file
View file

@ -0,0 +1,48 @@
name: 'Create Release Pull Request'
on:
create:
branches:
- releases/*
jobs:
build:
name: Create Release Pull Request
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v2
if: ${{ !contains(github.ref, 'test') }}
- name: Create Pull Request content
if: ${{ !contains(github.ref, 'test') }}
run: |
PR_TITLE=`./script/draft-release/release-pr-content.sh title ${GITHUB_REF#refs/heads/}`
PR_BODY=`./script/draft-release/release-pr-content.sh body ${GITHUB_REF#refs/heads/}`
echo "PR_BODY<<EOF" >> $GITHUB_ENV
echo "$PR_BODY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
echo "PR_TITLE<<EOF" >> $GITHUB_ENV
echo "$PR_TITLE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- uses: tibdex/github-app-token@v1
id: generate-token
if: ${{ !contains(github.ref, 'test') }}
with:
app_id: ${{ secrets.DESKTOP_RELEASES_APP_ID }}
private_key: ${{ secrets.DESKTOP_RELEASES_APP_PRIVATE_KEY }}
- name: Create Release Pull Request
uses: peter-evans/create-pull-request@v4.0.4
if: ${{ !contains(github.ref, 'test') }}
with:
token: ${{ steps.generate-token.outputs.token }}
title: ${{ env.PR_TITLE }}
body: ${{ env.PR_BODY }}
branch: ${{ github.ref }}
base: development
reviewers: desktop

View file

@ -0,0 +1,49 @@
#!/bin/sh
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <title|body> <branch-name>"
exit 1
fi
OUTPUT_TYPE=$1
BRANCH_NAME=$2
VERSION=$(echo ${BRANCH_NAME#releases/})
# For title just echo "Release version"
if [ "$OUTPUT_TYPE" = "title" ]; then
echo "Release ${VERSION}"
exit 0
fi
# If output type is not body, exit
if [ "$OUTPUT_TYPE" != "body" ]; then
echo "Unknown output type: $OUTPUT_TYPE"
exit 1
fi
RELEASE_DESCRIPTION="v${VERSION} production release"
if [[ "$VERSION" == *"-"* ]]; then
BUILD_TYPE_AND_NUMBER=$(echo ${VERSION##*-})
if [[ "$BUILD_TYPE_AND_NUMBER" != *"beta" ]]; then
echo "Only beta and production builds have release PRs"
fi
BUILD_TYPE="beta"
BUILD_NUMBER=$(echo ${BUILD_TYPE_AND_NUMBER:4})
case $BUILD_NUMBER in
*1[0-9] | *[04-9]) BUILD_NUMBER_SUFFIX="th";;
*1) BUILD_NUMBER_SUFFIX="st";;
*2) BUILD_NUMBER_SUFFIX="nd";;
*3) BUILD_NUMBER_SUFFIX="rd";;
esac
RELEASE_DESCRIPTION="${BUILD_NUMBER}${BUILD_NUMBER_SUFFIX} beta of the v${VERSION} series"
fi
echo "## Description
Looking for the PR for the upcoming ${RELEASE_DESCRIPTION}? Well, you've just found it, congratulations!
## Release checklist
- [ ] Check to see if there are any errors in Sentry that have only occurred since the last production release
- [ ] Verify that all feature flags are flipped appropriately
- [ ] If there are any new metrics, ensure that central and desktop.github.com have been updated"