-
Notifications
You must be signed in to change notification settings - Fork 9
68 lines (64 loc) · 2.42 KB
/
twios.yaml
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
on:
schedule:
# Every Sunday 23:00
- cron: '0 23 * * 0'
pull_request:
types: [labeled, unlabeled]
issue_comment:
types: [edited]
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TWIOS_BRANCH: ${{ github.event.pull_request.head.ref || 'master' }}
TWIOS_PR_REF: ${{ github.event.pull_request.head.ref }}
permissions:
pull-requests: write
jobs:
create_twios:
runs-on: ubuntu-latest
if: ${{!github.event.pull_request.body && github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event.label.name == 'twios'}}
steps:
- uses: actions/checkout@v3
- name: Fetch $TWIOS_BRANCH
run: |
git fetch origin $TWIOS_BRANCH
git checkout $TWIOS_BRANCH
- name: Configure local git
run: |
git config --global user.email "twios@twios_test_dev.com"
git config --global user.name "TWIOS Dev"
- name: Generate Comment
run: |
GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN ./twios/this-week.sh comment
- name: Generate TWIOS
run: GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN ./twios/this-week.sh
- name: Push new TWIOS
run: |
FORMATTED_DATE="$(date +"%Y-%m-%d")"
BRANCH_NAME="twios-$FORMATTED_DATE"
git checkout -b $BRANCH_NAME
git add **/*.md **/*.json && git commit -m "$BRANCH_NAME"
git push --set-upstream origin $BRANCH_NAME
gh pr create --base main --head $BRANCH_NAME --title "TWIOS $FORMATTED_DATE" --body-file comment.txt
edit_twios:
runs-on: ubuntu-latest
if: ${{github.event.pull_request.body && contains(github.event.pull_request.head.ref, 'twios')}}
steps:
- uses: actions/checkout@v3
- name: Fetch $TWIOS_PR_REF
run: |
git fetch origin $TWIOS_PR_REF
git checkout $TWIOS_PR_REF
- name: Configure local git
run: |
git config --global user.email "twios@twios_test_dev.com"
git config --global user.name "TWIOS Dev"
- name: Read PR comment body
run: |
GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN ./twios/this-week.sh comment --comment="${{ github.event.pull_request.body }}"
- name: Generate TWIOS
run: GITHUB_PERSONAL_TOKEN=$GITHUB_TOKEN ./twios/this-week.sh -edit
- name: Push updated TWIOS
run: |
git add **/*.md **/*.json && git commit -m "Edited $TWIOS_PR_REF"
git push