-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
55 lines (53 loc) · 1.84 KB
/
build-json.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
name: Deploy Latest JSON Checklist
on:
push:
branches:
- master
paths:
- 'document/**'
workflow_dispatch:
jobs:
create_pr:
name: Create Pull Request
runs-on: ubuntu-latest
steps:
- name: Setup Action
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install Dependencies
run: |
sudo apt update
sudo apt install moreutils
- name: Git Setup Global Config
run: |
# Git setup
export GITHUB_USER=wstgbot
echo "GITHUB_USER=$GITHUB_USER" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.wstg_deploy_token }}" >> $GITHUB_ENV
git config --global user.email "62450690+wstgbot@users.noreply.github.com"
git config --global user.name $GITHUB_USER
- name: Setup Environment Variables
run : |
# Setup some env vars etc for future use
echo "SRC_BASE="OWASP/wstg@"$(git log -1 --format=format:%h)" >> $GITHUB_ENV
echo "BRANCH_STAMP=$(date +"%Y%m%d%H%M%S")" >> $GITHUB_ENV
echo "SHORT_DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV
- name: Create Feature Branch
run: |
# Checkout what will be the new feature branch
git checkout -b $BRANCH_STAMP
- name: Run JSON Build
run: npm run-script jsongen
- name: Push Feature Branch and Raise PR
run: |
# If there are changes: add, commit, PR
git add checklist/checklist.json
if ! git diff-index --quiet HEAD --; then
git remote set-url origin https://$GITHUB_USER:${{ secrets.wstg_deploy_token }}@github.com/OWASP/wstg.git
git commit -m "Publish Latest JSON checklist $SHORT_DATE" -m "Updates based on $SRC_BASE"
git push --set-upstream origin $BRANCH_STAMP
hub pull-request --no-edit
fi