Skip to content

Download Pastebin to JSON #14

Download Pastebin to JSON

Download Pastebin to JSON #14

Workflow file for this run

name: Download Pastebin to JSON
on:
workflow_dispatch:
inputs:
pastebin_url:
description: "Pastebin URL"
required: true
type: string
jobs:
download-and-commit:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Pastebin content
run: |
PASTE_ID=$(echo ${{ github.event.inputs.pastebin_url }} | awk -F'/' '{print $NF}')
PASTE_TITLE=$(curl -s "${{ github.event.inputs.pastebin_url }}" | grep -o '<title>.*</title>' | sed 's/<title>\(.*\) - Pastebin\.com<\/title>/\1/')
SANITIZED_TITLE=$(echo "$PASTE_TITLE" | sed 's/[^a-zA-Z0-9._-]/_/g')
curl -s https://pastebin.com/raw/$PASTE_ID | jq '.' > "drpd/${SANITIZED_TITLE}.json"
echo "SANITIZED_TITLE=$SANITIZED_TITLE" >> $GITHUB_ENV
- name: Commit and push if there are changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add "drpd/$SANITIZED_TITLE.json"
git diff --quiet && git diff --staged --quiet || (git commit -m "Add drpd JSON" && git push)