Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
105 lines (103 sloc) 3.73 KB
name: new-pull-request
on:
release:
types:
- published
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git fetch origin master
- name: Git config
run: |
git config --local user.email "oinume@gmail.com"
git config --local user.name "actions"
- name: Create local changes
run: |
CURRENT_VERSION=$(echo $GITHUB_REF | sed 's/refs\/tags\///')
echo "CURRENT_VERSION = $CURRENT_VERSION"
NEXT_VERSION=$(echo $CURRENT_VERSION | perl -ne 'if ($_ =~ /^(\d+)\.(\d+)\.\d+$/) { $v = $2; $v++; print "$1.$v.0\n" } else { print "Invalid tag format."; exit 1 }')
echo "NEXT_VERSION = $NEXT_VERSION"
echo "::set-env name=NEXT_VERSION::$(echo $NEXT_VERSION)"
- name: Get release date
run: |
echo "::set-env name=RELEASE_DATE::$(echo 2020-02-29)"
- name: Create milestone
id: create_milestone
uses: WyriHaximus/github-action-create-milestone@0.1.0
with:
title: ${{ env.NEXT_VERSION }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Check milestone is created
if: steps.create_milestone.outputs.number == 'null'
run: |
echo "Milestone number is null"
exit 1
- name: Empty commit
run: |
git checkout master
git commit --allow-empty -m "Empty commit for $NEXT_VERSION"
- name: Create a pull request with a new release branch
id: create_pull_request
uses: peter-evans/create-pull-request@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: release/${{ env.NEXT_VERSION }}
base: master
title: "Release ${{ env.NEXT_VERSION }} (${{ env.RELEASE_DATE }})"
body: |
## For developers
Link this milestone to your pull-request after merge.
https://github.com/${{ github.repository }}/milestone/${{ steps.create_milestone.outputs.number }}
- name: Post to slack
uses: 8398a7/action-slack@v2
with:
status: custom
payload: |
{
"text": "`release/${{ env.NEXT_VERSION }}` was created. This is a release branch for next release.",
"attachments": [{
"color": "good",
"fallback": "`release/${{ env.NEXT_VERSION }}` was created. This is a release branch for next release.",
"fields": [
{
"title": "Pull Request",
"value": "https://github.com/${{ github.repository }}/pull/${{ steps.create_pull_request.outputs.pr_number }}",
"short": false
},
{
"title": "Milestone",
"value": "https://github.com/${{ github.repository }}/milestone/${{ steps.create_milestone.outputs.number }}",
"short": false
}
]
}]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
- name: Post to slack when failure
uses: 8398a7/action-slack@v2
with:
status: custom
payload: |
{
"text": "Failed to create `release/${{ env.NEXT_VERSION }}` branch. Maybe the branch already exists.",
"attachments": [{
"color": "warning",
"fields": [
{
"title": "Branch URL",
"value": "https://github.com/${{ github.repository }}/tree/release/${{ env.NEXT_VERSION }}",
"short": false
}
]
}]
}
if: failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
You can’t perform that action at this time.