forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 4
76 lines (65 loc) · 2.24 KB
/
create-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Create PR
on:
workflow_dispatch:
inputs:
tags:
description: 'target commit hash'
required: false
type: string
push:
branches:
- 'dev-kakurega'
- 'next-release'
paths:
- 'package.json'
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: get package version
id: package-version
uses: martinbeentjes/npm-get-version-action@v1.3.1
- name: check tag exists
uses: mukunku/tag-exists-action@v1.4.0
id: check-tag
with:
tag: v${{ steps.package-version.outputs.current-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: check pr exists
id: check-pr
run: |
echo "Checking PR exists"
echo "Using repository: ${{ github.repository }}"
gh repo set-default ${{ github.repository }}
MISSKEY_VERSION=$(echo '${{ steps.package-version.outputs.current-version }}' | cut -d '-' -f 1)
COUNT=$(gh pr list -S 'release in:title' --json title --jq '.[].title' | grep $MISSKEY_VERSION | wc -l)
if [ $((COUNT)) -gt 0 ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "PR already exists"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "PR does not exist"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: create pull request
if: steps.check-tag.outputs.exists == 'false' && steps.check-pr.outputs.exists == 'false'
shell: bash
run: |
if [ -z "${{ inputs.tags }}" ]; then
TAG=$(git rev-parse HEAD)
fi
echo "Creating PR"
COMMAND_ARGS=(-B "master-kakurega" -H "${{ github.ref_name }}" -t "release: v${{ steps.package-version.outputs.current-version }}" -b "Automated pr by github actions")
if git log "$TAG" -1 --pretty=%B | grep -E "^Merge tag '.+-(alpha|beta|rc).+'"; then
COMMAND_ARGS+=(--draft)
fi
gh pr create "${COMMAND_ARGS[@]}"
echo "PR created"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tags }}