Fully integrated Anytype Space #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
issues: | |
types: [labeled] | |
name: Parse New Experience | |
jobs: | |
new_experience: | |
if: github.event.label.name == 'experience' | |
runs-on: ubuntu-latest | |
permissions: | |
issues: write | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: stefanbuck/github-issue-parser@v3 | |
id: issue-parser | |
with: | |
template-path: .github/ISSUE_TEMPLATE/new_experience.yml | |
- run: echo '${{ steps.issue-parser.outputs.jsonString }}' > issue.json | |
- run: | | |
echo "experience_name=$(echo '${{ steps.issue-parser.outputs.issueparser_title }}' | sed -e 's/[^[:alnum:]]/_/g' | tr -s '_' | tr A-Z a-z)" >> "$GITHUB_ENV" | |
echo "id=$(uuidgen)" >> "$GITHUB_ENV" | |
- run: | | |
jq '. + {"author": "${{ github.event.issue.user.login }}", "name": "${{ env.experience_name }}", "id": "${{ env.id }}"}' issue.json > tmp && mv tmp issue.json | |
- id: manifest-builder | |
run: | | |
node tools/prepare-experience.js | |
rm issue.json | |
sudo apt update | |
sudo apt install snapd | |
sudo snap install pngquant | |
pngquant --force --ext=.png experiences/${{ env.experience_name }}/screenshots/*.png | |
file_size=$(stat -c %s "experiences/${{ env.experience_name }}/${{ env.experience_name }}.zip") | |
jq --arg file_size $file_size '.fileSize = ($file_size|tonumber)' "experiences/${{ env.experience_name }}/manifest.json" > temp.json && mv temp.json "experiences/${{ env.experience_name }}/manifest.json" | |
rm -f temp.json | |
jq --arg file_size $file_size '.fileSize = ($file_size|tonumber)' "experiences/${{ env.experience_name }}/test-manifest.json" > temp.json && mv temp.json "experiences/${{ env.experience_name }}/test-manifest.json" | |
rm -f temp.json | |
echo "test-manifest=anytype://main/import/?type=experience&source=https%3A%2F%2Fgithub.com%2Fanyproto%2Fgallery%2Fraw%2F${{ env.experience_name }}%2Fexperiences%2F${{ env.experience_name }}%2Ftest-manifest.json" >> "$GITHUB_ENV" | |
- name: Create Pull Request | |
id: cpr | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: "Add preview for ${{ steps.issue-parser.outputs.issueparser_title }}" | |
committer: "Any Association <[email protected]>" | |
branch: ${{ env.experience_name }} | |
delete-branch: true | |
title: "Add experience ${{ steps.issue-parser.outputs.issueparser_title }}" | |
body: "Based on issue #${{ github.event.issue.number }}" | |
- name: Comment on Issue | |
run: gh issue comment "$NUMBER" --body "$BODY" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_REPO: ${{ github.repository }} | |
NUMBER: ${{ github.event.issue.number }} | |
BODY: > | |
Thanks for your contribution! :tada: | |
I have created a pull request #${{ steps.cpr.outputs.pull-request-number }} based on data you provided. | |
If everything worked correctly, you can test the Experience: | |
[${{ env.test-manifest }}](${{ env.test-manifest }}) | |
The Experience will be added to the Gallery after someone from the Any team reviews it. |