-
Notifications
You must be signed in to change notification settings - Fork 22
115 lines (110 loc) · 4.14 KB
/
master-CI.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Continuous integration
on:
push:
branches:
- master
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: dprint/check@v1.5
- uses: actions/setup-node@v1
- run: yarn install
- run: yarn test
create-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git config user.email noreply@github.com
git config user.name "GitHub actions"
git checkout -b feature/test/${{ github.sha }}
echo date > current-date.txt
git add current-date.txt
git commit --message "Some changes"
git push origin feature/test/${{ github.sha }}
- uses: ./
id: create-pr
with:
head: feature/test/${{ github.sha }}
title: Testing commit ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate that PR exists
run: curl --fail https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-pr.outputs.number }}
- name: Close PR
run: |
curl \
-X PATCH \
-H 'Accept: application/vnd.github.v3+json' \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-pr.outputs.number }} \
-d '{"state":"closed"}'
if: always()
create-draft-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git config user.email noreply@github.com
git config user.name "GitHub actions"
git checkout -b feature/test/${{ github.sha }}-draft
echo date > current-date.txt
git add current-date.txt
git commit --message "Some changes"
git push origin feature/test/${{ github.sha }}-draft
- uses: ./
id: create-draft-pr
with:
head: feature/test/${{ github.sha }}-draft
title: Testing commit ${{ github.sha }}
draft: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate that PR exists
run: |
curl \
-H 'Accept: application/vnd.github.shadow-cat-preview+json' \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-draft-pr.outputs.number }} \
--fail \
- name: Close PR
run: |
curl \
-X PATCH \
-H 'Accept: application/vnd.github.v3+json' \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-draft-pr.outputs.number }} \
-d '{"state":"closed"}'
if: always()
create-pr-with-reviewers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
git config user.email noreply@github.com
git config user.name "GitHub actions"
git checkout -b feature/test/${{ github.sha }}-reviewers
echo date > current-date.txt
git add current-date.txt
git commit --message "Some changes"
git push origin feature/test/${{ github.sha }}-reviewers
- uses: ./
id: create-pr-with-reviewers
with:
head: feature/test/${{ github.sha }}-reviewers
title: Testing commit ${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
reviewers: thomaseizinger
- name: Validate that PR exists
run: curl --fail https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-pr-with-reviewers.outputs.number }}
- name: Close PR
run: |
curl \
-X PATCH \
-H 'Accept: application/vnd.github.v3+json' \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create-pr-with-reviewers.outputs.number }} \
-d '{"state":"closed"}'
if: always()