[Convert] https://api.pastes.dev/2LAFIRLm20 #8
This file contains hidden or 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: Convert survey JSON from issue | |
| on: | |
| issues: | |
| types: | |
| - labeled | |
| jobs: | |
| from-issue: | |
| # Run when the "convert" label is applied | |
| if: github.event.label.name == 'convert' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Parse issue form data | |
| id: parse | |
| uses: zentered/issue-forms-body-parser@v1.5.1 | |
| - name: Extract inputs | |
| id: extract | |
| run: | | |
| # Write parsed issue form data (already JSON) to a file | |
| echo '${{ steps.parse.outputs.data }}' > issue-data.json | |
| # Field IDs from the issue form: | |
| # - raw-survey-json-url | |
| # - config-source | |
| # - configuration-file | |
| # - custom-configuration-file-json-format | |
| # Extract values | |
| JSON_URL=$(jq -r '."raw-survey-json-url".text' issue-data.json) | |
| # Strip surrounding < > if present (issue forms wrap links that way) | |
| JSON_URL=${JSON_URL#<} | |
| JSON_URL=${JSON_URL%>} | |
| CONFIG_SOURCE=$(jq -r '."config-source".text' issue-data.json) | |
| CONFIG_FILE=$(jq -r '."configuration-file".text' issue-data.json) | |
| echo "json_url=$JSON_URL" >> $GITHUB_OUTPUT | |
| echo "config_source=$CONFIG_SOURCE" >> $GITHUB_OUTPUT | |
| echo "config_file=$CONFIG_FILE" >> $GITHUB_OUTPUT | |
| - name: Download survey JSON | |
| run: | | |
| URL="${{ steps.extract.outputs.json_url }}" | |
| if [ -z "$URL" ] || [ "$URL" = "null" ] || [ "$URL" = "*No response*" ]; then | |
| echo "Error: No valid JSON URL provided in the issue form (got '$URL')." >&2 | |
| exit 1 | |
| fi | |
| curl -L "$URL" -o survey.json | |
| - name: Prepare config (custom only) | |
| run: | | |
| if [ "${{ steps.extract.outputs.config_source }}" = "Paste custom config JSON below" ]; then | |
| jq -r '."custom-configuration-file-json-format".text' issue-data.json > config.runtime.json | |
| fi | |
| - name: Run converter | |
| run: | | |
| if [ "${{ steps.extract.outputs.config_source }}" = "Use config from configs/ folder" ]; then | |
| python convert.py survey.json --config-name="${{ steps.extract.outputs.config_file }}" | |
| else | |
| python convert.py survey.json --config=config.runtime.json | |
| fi | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: survey-conversion | |
| path: | | |
| survey.bbcode.txt | |
| survey.csv | |
| if-no-files-found: error | |
| - name: Comment on issue with artifact link | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.issue.number }} | |
| body: | | |
| ## ✅ Survey conversion finished | |
| You can download the BBCode and CSV artifacts from this workflow run: | |
| https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} | |