Skip to content

Append data to list #195

Append data to list

Append data to list #195

name: Append data to list
concurrency: listappend-${{ github.ref }}
on:
workflow_dispatch:
inputs:
file:
description: "The file in the Lists directory to append to"
required: true
default: "scams.txt"
text:
description: "The text to append to the end of the list"
required: true
user:
description: "The Discord user to credit for the addition"
required: true
jobs:
fileappend:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Check file exists
run: |
if [ ! -f Lists/${{ github.event.inputs.file }} ]; then
echo "File not found!"
exit 1
fi
- name: Append to file
uses: Erisa/write-file-action@master
with:
path: Lists/${{ github.event.inputs.file }}
contents: |
${{ github.event.inputs.text }}
write-mode: append-newline
- name: Setup git config
run: |
git config user.name "GitHub Actions via Discord user ${{ github.event.inputs.user }}"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Commit and push
run: |
git add .
git commit -m "${{ github.event.inputs.user }}: Update ${{ github.event.inputs.file }}"
git push
- name: Trigger rebuild
run: |
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
gh workflow run docker-push.yml --ref main
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}