-
-
Notifications
You must be signed in to change notification settings - Fork 172
90 lines (81 loc) · 3.11 KB
/
update-styles.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
name: Weekly Styles Update
on:
workflow_dispatch:
inputs:
name:
description: 'Person who triggered the workflow'
required: true
default: 'scheduled run'
schedule:
# Run every Wednesday
- cron: '0 0 * * 3'
jobs:
check-token:
name: "Check STYLES_WORKFLOW token"
runs-on: ubuntu-latest
if: ${{ github.repository == 'carpentries/lesson-example' }}
outputs:
wf: ${{ steps.validate.outputs.wf }}
repo: ${{ steps.validate.outputs.repo }}
steps:
- name: "validate token"
id: validate
uses: carpentries/actions/check-valid-credentials@main
with:
token: ${{ secrets.STYLES_WORKFLOW }}
bad-token:
name: "Invalid/Missing Token"
runs-on: ubuntu-latest
needs: check-token
if: ${{ needs.check-token.outputs.wf != 'true' && github.repository == 'carpentries/lesson-example' }}
steps:
- name: "Instructions to create a new token"
run: |
printf "::warning::The STYLES_WORKFLOW secret is missing, invalid, "\
"or does not have the right scope to update workflows.\n"\
"If you want to have automated pull request updates to your workflows, "\
"you will need to generate a new token by visiting "\
"https://github.com/settings/tokens/new?scopes=repo,workflow&description=Styles%%20Token\n"\
"Once you have created the token, go to "\
"https://github.com/${{ github.repository }}/settings/secrets/actions/STYLES_WORKFLOW "\
"to update it."
update-styles:
runs-on: ubuntu-latest
name: Styles Update
needs: check-token
if: ${{ needs.check-token.outputs.wf == 'true' && github.repository == 'carpentries/lesson-example' }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Record Date
id: today
run: |
echo "::set-output name=date::$(date -I)"
echo "::set-output name=min::$(date +%Y-%m-%d-%H-%M)"
- name: Sync lesson with carpentries/styles
id: update
uses: carpentries/actions/update-styles@main
env:
LESSON: "Lesson Example"
REF: ${{ github.ref }}
with:
commit: true
- name: Create Pull Request
id: cpr
if: ${{ steps.update.outputs.update == 'true' }}
uses: peter-evans/[email protected]
with:
token: ${{ secrets.STYLES_WORKFLOW}}
commit-message: "[actions] Sync lesson with carpentries/styles"
branch: "update-styles-${{ steps.today.outputs.min }}"
delete-branch: true
title: "Update Styles (${{ steps.today.outputs.date }} via ${{ github.event.inputs.name }})"
body: |
Update styles repository. Please inspect the changes to make sure there are no conflicts with your lesson.
- Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: "type:template and tools"
# NOTE: This tag is repository-specific
team-reviewers: core-team-curriculum
draft: false