Skip to content

Update (1042) The Stone Vigil.json #2

Update (1042) The Stone Vigil.json

Update (1042) The Stone Vigil.json #2

name: path-mdf-calc-onanychange
on:
pull_request:
types:
- closed
jobs:
workflow:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
name: path-mdf-calc-onanychange
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed files in the paths folder
id: changed-files-specific
uses: tj-actions/[email protected]
with:
safe_output: "false"
quotepath: "false"
files: AutoDuty/Paths/**
separator: ","
- name: Calculate MD5 hashes and create JSON
if: steps.changed-files-specific.outputs.any_changed == 'true'
id: calculate-md5
run: |
mkdir -p AutoDuty/Paths
md5sum AutoDuty/Paths/* > md5sums.txt
python -c "
import json
md5_dict = {}
with open('md5sums.txt', 'r') as f:
for line in f:
hash, filename = line.strip().split(' ')
md5_dict[filename] = hash
with open('AutoDuty/Paths/md5s.json', 'w') as f:
json.dump(md5_dict, f, indent=4)
"
cat AutoDuty/Paths/md5s.json
- name: Commit changes to new branch
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git checkout -b md5 origin/main
git add AutoDuty/Paths/md5s.json
git commit -m 'Add MD5 hashes for changed files'
git push origin md5
- name: Create pull request
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
PR_DATA=$(jq -n --arg title "Add MD5 hashes for changed files" --arg body "This PR adds MD5 hashes for the changed files in the AutoDuty/Paths folder." --arg head "md5" --arg base "main" '{title: $title, body: $body, head: $head, base: $base}')
curl -X POST -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/ffxivcode/AutoDuty/pulls -d "$PR_DATA"
- name: Merge pull request
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
PR_NUMBER=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/ffxivcode/AutoDuty/pulls?head=ffxivcode:md5 | jq '.[0].number')
curl -X PUT -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/ffxivcode/AutoDuty/pulls/$PR_NUMBER/merge -d '{"merge_method":"merge"}'
- name: Delete branch
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
git push origin --delete md5