theme-store/.github/workflows/create-theme.yml

126 lines
4.3 KiB
YAML

on:
issues:
types: [opened]
jobs:
createPR:
permissions: write-all
name: Submit a theme
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Parse issue
id: parse
uses: onmax/issue-form-parser@v1.5
with:
issue_number: ${{ github.event.issue.number }}
# Examples on how to use the output
- name: Show parsed payload data
run: |
# Using the character `'` to prevent all characters enclosed within
# them from being treated as special characters (e.g. $ or `)
echo '${{ steps.parse.outputs.payload }}'
- name: Export parsed payload into variables
id: export
run: |
export THEME_NAME='${{ fromJson(steps.parse.outputs.payload)['Name'] }}'
export THEME_DESCRIPTION='${{ fromJson(steps.parse.outputs.payload)['Description'] }}'
export THEME_HOMEPAGE='${{ fromJson(steps.parse.outputs.payload)['Homepage'] }}'
export THEME_STYLES='${{ fromJson(steps.parse.outputs.payload)['Theme Styles'] }}'
export THEME_README='${{ fromJson(steps.parse.outputs.payload)['Readme'] }}'
export THEME_AUTHOR='${{ github.actor }}'
- 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 branch
run: |
git checkout -b create-theme-${{ github.event.issue.number }}
- name: Create theme content
run: |
python3 scripts/submit-theme.py \
--name "${THEME_NAME}" \
--description "${THEME_DESCRIPTION}" \
--homepage "${THEME_HOMEPAGE}" \
--styles "${THEME_STYLES}" \
--readme "${THEME_README}" \
--author "${THEME_AUTHOR}" 2> error.log
export CREATION_OUTPUT=$(cat error.log)
- 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.
```
${{ steps.export.outputs.CREATION_OUTPUT }}
```
- if: success()
name: Commit changes
run: |
git add themes/
git commit -m "Add theme: $THEME_NAME"
git push origin create-theme-${{ github.event.issue.number }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Add theme: $THEME_NAME"
title: "Add theme: $THEME_NAME"
body: |
# Add theme: $THEME_NAME
This PR adds a new theme to the theme library.
## Theme Details
* **Name**: $THEME_NAME
* **Description**: $THEME_DESCRIPTION
* **Homepage**: $THEME_HOMEPAGE
* **Author**: @$THEME_AUTHOR
## Theme Styles
```css
$THEME_STYLES
```
## Theme README
```markdown
$THEME_README
```
branch: create-theme-${{ github.event.issue.number }}
base: main
- if: startsWith(github.event.issue.title, '[create-theme]:') != 'true' && success()
name: Close Issue
uses: peter-evans/close-issue@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment: |
# Thank you for your contribution!
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](${{ steps.createPR.outputs.pull-request-url }}).
* 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.