-
-
Notifications
You must be signed in to change notification settings - Fork 40
129 lines (108 loc) · 4.88 KB
/
create-theme.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Create Theme
on:
issues:
types: [opened]
jobs:
createPR:
permissions: write-all
name: Submit a theme
runs-on: ubuntu-latest
if: startsWith(github.event.issue.title, '[create-theme]:')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Setup python modules
run: |
pip3 install requests
- name: Parse issue
id: issue-parser
uses: stefanbuck/github-issue-parser@v3
with:
template-path: .github/ISSUE_TEMPLATE/create-theme.yml
- name: Export parsed payload into variables
id: export
run: |
echo "THEME_NAME=${{ fromJson(steps.issue-parser.outputs.jsonString)['name'] }}" >> $GITHUB_ENV
echo "THEME_DESCRIPTION=${{ fromJson(steps.issue-parser.outputs.jsonString)['description'] }}" >> $GITHUB_ENV
echo "THEME_HOMEPAGE=${{ fromJson(steps.issue-parser.outputs.jsonString)['homepage'] }}" >> $GITHUB_ENV
echo "THEME_IMAGE=${{ fromJson(steps.issue-parser.outputs.jsonString)['image'] }}" >> $GITHUB_ENV
echo "THEME_AUTHOR=${{ github.event.issue.user.login }}" >> $GITHUB_ENV
echo "THEME_IS_COLOR_THEME=${{ contains(fromJson(steps.issue-parser.outputs.jsonString)['is-color-theme'], 'JSON Color Theme') }}" >> $GITHUB_ENV
- name: Write styles to file
uses: 'DamianReeves/write-file-action@master'
with:
contents: ${{ fromJson(steps.issue-parser.outputs.jsonString)['styles'] }}
path: theme-styles.css
- name: Write readme to file
uses: 'DamianReeves/write-file-action@master'
with:
contents: ${{ fromJson(steps.issue-parser.outputs.jsonString)['readme'] }}
path: theme-readme.md
- name: Write preferences to file
uses: 'DamianReeves/write-file-action@master'
if: fromJson(steps.issue-parser.outputs.jsonString)['preferences'] != ''
with:
contents: ${{ fromJson(steps.issue-parser.outputs.jsonString)['preferences'] }}
path: theme-preferences.json
- name: Setup Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Create theme content
run: |
python3 scripts/submit_theme.py \
--name "${{ env.THEME_NAME }}" \
--description "${{ env.THEME_DESCRIPTION }}" \
--author "${{ env.THEME_AUTHOR }}" \
--image "${{ env.THEME_IMAGE }}" \
--is-color-theme "${{ env.THEME_IS_COLOR_THEME }}" \
--homepage "${{ env.THEME_HOMEPAGE }}" 2> error.log
- name: Export creation output
if: failure()
run: |
cat error.log
echo "CREATION_OUTPUT=$(cat error.log)" >> $GITHUB_ENV
- name: Show error message
if: failure()
uses: peter-evans/close-issue@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment: |
# Error creating theme
Sorry about that! There was an error creating the theme. Please try again or contact the maintainers for help.
> ${{ env.CREATION_OUTPUT }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
if: success()
with:
add-paths: themes/
labels: staged
token: ${{ secrets.DEPLOY_KEY }}
commit-message: 'Add theme: ${{ env.THEME_NAME }}'
delete-branch: true
title: 'Add theme: ${{ env.THEME_NAME }}'
body: |
# Add theme: ${{ env.THEME_NAME }}
This PR adds a new theme to the theme library.
## Theme Details
* **Name**: ${{ env.THEME_NAME }}
* **Description**: ${{ env.THEME_DESCRIPTION }}
* **Homepage**: ${{ env.THEME_HOMEPAGE }}
* **Author**: @${{ env.THEME_AUTHOR }}
branch: create-theme-${{ github.event.issue.number }}
base: main
- name: Close Issue
uses: peter-evans/close-issue@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment: |
# Thank you for your contribution! :tada:
Your theme has been successfully submitted. The maintainers will review it and get back to you soon.
Here are some details about your submission:
* Your theme has been requested into [this PR](https://github.com/zen-browser/theme-store/pull/${{ env.PULL_REQUEST_NUMBER }}).
* It has been created into the [create-theme-${{ github.event.issue.number }} branch](https://github.com/zen-browser/theme-store/tree/create-theme-${{ github.event.issue.number }}).
> If you have any questions or need help, feel free to ask in the comments below or in the PR.