Skip to content

Update (1039) The Thousand Maws of TotoRak.json #9

Update (1039) The Thousand Maws of TotoRak.json

Update (1039) The Thousand Maws of TotoRak.json #9

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/mdfs.json', 'w') as f:
json.dump(md5_dict, f, indent=4)
"
cat AutoDuty/Paths/mdfs.json
- name: Commit changes to new md5 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
git add AutoDuty/Paths/mdfs.json
git commit -m 'Update MD5 hashes'
git push origin md5
- name: Create pull request
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: peter-evans/[email protected]
with:
branch: md5
title: 'Update MD5 hashes'
body: 'This PR updates MD5 hashes because there were changed files in the AutoDuty/Paths folder.'
- name: Merge pull request
if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: actions/[email protected]
with:
script: |
const { data: pullRequest } = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: 'md5'
});
if (pullRequest.length > 0) {
await github.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequest[0].number
});
}
- name: Delete branch
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
git push origin --delete md5