-
Notifications
You must be signed in to change notification settings - Fork 23
64 lines (53 loc) · 1.79 KB
/
validate-drafts.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
name: Validate draft authors
on:
pull_request_target:
branches:
- main
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${{github.head_ref}})"
id: extract_branch
- uses: actions/checkout@v2
with:
repository: "${{ github.event.pull_request.user.login }}/genicsblog.com"
ref: "${{ steps.extract_branch.outputs.branch }}"
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
drafts:
- '_drafts/**'
- name: Get all changed files
if: steps.filter.outputs.drafts == 'true'
id: files
uses: Ana06/get-changed-files@v2.1.0
- uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install python dependencies
if: steps.filter.outputs.drafts == 'true'
run: |
pip install python-frontmatter PyYAML requests
- name: Get validation script from main branch
if: steps.filter.outputs.drafts == 'true'
run: |
rm -rf _scripts
wget https://raw.githubusercontent.com/genicsblog/theme-files/main/_scripts/validate-drafts.py -P _scripts
- name: Validate draft author
if: steps.filter.outputs.drafts == 'true'
run: |
echo "${{ steps.files.outputs.all }}" >> temp.txt
python _scripts/validate-drafts.py ${{ github.event.pull_request.user.login }}
rm temp.txt
- name: Auto-merge if no errors
if: steps.filter.outputs.drafts == 'true'
uses: "pascalgn/automerge-action@v0.14.3"
env:
GITHUB_TOKEN: "${{ secrets.COMMIT_TOKEN }}"
MERGE_LABELS: ""
MERGE_METHOD: "squash"
MERGE_COMMIT_MESSAGE: "Auto merge changes to drafts #{pullRequest.number}"