Spotify Plugin 1.4.0 #31
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
name: Compile Extension | |
on: | |
pull_request_target: | |
branches: [ "main" ] | |
types: [opened, synchronize, reopened] | |
jobs: | |
setup: | |
name: "Setup" | |
runs-on: ubuntu-latest | |
outputs: | |
extension-path: ${{ steps.extract-extension-path.outputs.path }} | |
steps: | |
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 | |
with: | |
labels: in-process | |
- uses: actions-ecosystem/[email protected] | |
with: | |
labels: | | |
author-actions-required | |
build-failed | |
invalid-manifest | |
moderator-review-required | |
tests-failed | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: "${{ github.event.pull_request.merge_commit_sha }}" | |
- name: Extract extension path | |
id: extract-extension-path | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
pr_paths=$(gh pr view ${{ github.event.pull_request.number }} --json files) | |
files_count=$(jq '.files | length' <<< ${pr_paths}) | |
if [[ $files_count -gt 1 ]] | |
then | |
echo "Only one extension per pull-request is allowed!" | |
exit 1 | |
elif [[ $files_count -eq 0 ]] | |
then | |
echo "No extension was found" | |
exit 1 | |
fi | |
echo "path=$(jq -r '.files[0].path' <<< ${pr_paths})" >> $GITHUB_OUTPUT | |
- name: Check extension path | |
run: echo "${{ steps.extract-extension-path.outputs.path }}" | |
- uses: actions-ecosystem/[email protected] | |
if: failure() && (steps.extract-extension-path.outcome == 'failure') | |
with: | |
labels: in-process | |
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 | |
if: failure() && (steps.extract-extension-path.outcome == 'failure') | |
with: | |
labels: author-actions-required | |
build: | |
name: "Build" | |
needs: [ setup ] | |
runs-on: ubuntu-latest | |
outputs: | |
artifact-name: ${{ steps.build_extension.outputs.artifact-name }} | |
artifact-path: ${{ steps.build_extension.outputs.artifact-path }} | |
manifest: ${{ steps.build_extension.outputs.manifest }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
ref: "${{ github.event.pull_request.merge_commit_sha }}" | |
- name: Init Submodule | |
run: git submodule update --init --recursive ./${{ needs.setup.outputs.extension-path }} | |
- name: Build Extension | |
id: build_extension | |
uses: Macro-Deck-App/Actions/build-extension@main | |
with: | |
extension-path: ${{ needs.setup.outputs.extension-path }} | |
artifact-name: ${{ github.event.pull_request.number }} | |
- uses: actions-ecosystem/[email protected] | |
if: failure() && (steps.build_extension.outcome == 'failure') | |
with: | |
labels: in-process | |
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 | |
if: failure() && (steps.build_extension.outcome == 'failure') | |
with: | |
labels: | | |
author-actions-required | |
build-failed | |
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 | |
if: success() | |
with: | |
labels: moderator-review-required | |
- uses: actions-ecosystem/[email protected] | |
if: success() | |
with: | |
labels: | | |
in-process | |
deploy: | |
name: "Deploy" | |
environment: production | |
needs: [ build ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions-ecosystem/action-add-labels@1a9c3715c0037e96b97bb38cb4c4b56a1f1d4871 | |
with: | |
labels: approved | |
- uses: actions-ecosystem/[email protected] | |
with: | |
labels: moderator-review-required | |
- name: Download a Build Artifact | |
uses: actions/[email protected] | |
with: | |
name: ${{ github.event.pull_request.number }} | |
- name: Upload built files | |
id: upload-build-files | |
env: | |
AUTH_TOKEN: ${{ secrets.MACRO_DECK_API_TOKEN }} | |
uses: Macro-Deck-App/Actions/upload-extension@main | |
with: | |
extension-path: "${{ github.event.pull_request.number }}.zip" | |
api-token: ${{ env.AUTH_TOKEN }} | |
- name: Check upload response | |
if: | | |
fromJSON(steps.upload-build-files.outputs.response).success == false && | |
fromJSON(steps.upload-build-files.outputs.response).errorCode != 4 | |
run: | | |
echo "::error ::Failed to upload files to build server. Response: ${{ steps.upload-build-files.outputs.response }}" && exit 1 | |
- name: Notify new plugin | |
if: fromJSON(steps.upload-build-files.outputs.response).newPlugin == true | |
env: | |
extensionManifest: ${{ fromJSON(steps.upload-build-files.outputs.response).extensionManifest }} | |
response: ${{ fromJSON(steps.upload-build-files.outputs.response) }} | |
run: | | |
payload='{ | |
"toEveryone" : false, | |
"embed" : { | |
"color" : { | |
"r":0, | |
"g":1, | |
"b":0 | |
}, | |
"title": "🎉 ${{ format('[{0}] {1}', fromJSON(env.extensionManifest).type, fromJSON(env.extensionManifest).name) }} is now available in the Extension Store", | |
"fields" : [ | |
{ | |
"name": "Description", | |
"value": "${{ env.response.description }}", | |
"inline": false | |
}, | |
{ | |
"name": "Author", | |
"value": "${{ fromJSON(env.extensionManifest).author }}", | |
"inline": false | |
}, | |
{ | |
"name": "Repository URL", | |
"value": "${{ fromJSON(env.extensionManifest).repository }}", | |
"inline": false | |
} | |
] | |
} | |
}' | |
curl --fail-with-body -o "./bot-notify-response.json" -X POST \ | |
'https://bot.api.macro-deck.app/webhook/extension-store' \ | |
-H 'accept: */*' \ | |
-H "Authorization: ${{ secrets.BOT_TOKEN }}" \ | |
-H 'Content-Type: application/json' \ | |
-d "$payload" || cat "./bot-notify-response.json" | |
- name: Notify update plugin | |
if: fromJSON(steps.upload-build-files.outputs.response).newPlugin == false | |
env: | |
extensionManifest: ${{ fromJSON(steps.upload-build-files.outputs.response).extensionManifest }} | |
response: ${{ fromJSON(steps.upload-build-files.outputs.response) }} | |
newVersion: ${{ fromJSON(steps.upload-build-files.outputs.response).newVersion }} | |
run: | | |
payload='{ | |
"toEveryone" : false, | |
"embed" : { | |
"color" : { | |
"r":0, | |
"g":1, | |
"b":1 | |
}, | |
"title": "🚀 ${{ format('[{0}] {1}', fromJSON(env.extensionManifest).type, fromJSON(env.extensionManifest).name) }} was updated", | |
"fields" : [ | |
{ | |
"name": "Version", | |
"value": "${{ fromJSON(env.extensionManifest).type }} -> ${{ env.newVersion }}", | |
"inline": false | |
}, | |
{ | |
"name": "Repository URL", | |
"value": "${{ fromJSON(env.extensionManifest).repository }}", | |
"inline": false | |
} | |
] | |
} | |
}' | |
curl --fail-with-body -o "./bot-notify-response.json" -X POST \ | |
'https://bot.api.macro-deck.app/webhook/extension-store' \ | |
-H 'accept: */*' \ | |
-H "Authorization: ${{ secrets.BOT_TOKEN }}" \ | |
-H 'Content-Type: application/json' \ | |
-d "$payload" || cat "./bot-notify-response.json" |