Skip to content

Automated Mari Update #1472

Automated Mari Update

Automated Mari Update #1472

Workflow file for this run

---
name: Automated Mari Update
on:
schedule:
- cron: '13 3 * * *' # Run once a day at 3:13 AM
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check if PR already exists
id: check_pr
run: |
PR_EXISTS=$(curl -s "https://api.github.com/repos/fiaisis/autoreduction-scripts/pulls?state=open" | grep "AUTOMATED_SCRIPT_UPDATE_PR" | wc -c)
echo "::set-output name=exists::$PR_EXISTS"
# We are querying the api for all PRs then greping for the expected title, then checking the length of the output
# if the output length is not 0 then the PR already exists
- name: Checkout code
if: steps.check_pr.outputs.exists == '0'
uses: actions/checkout@v2
- name: Fetch the latest file contents
if: steps.check_pr.outputs.exists == '0'
run: curl -L "https://raw.githubusercontent.com/mantidproject/scriptrepository/master/direct_inelastic/MARI/template_mari.py" -o temp-file.py
- name: Compare files
if: steps.check_pr.outputs.exists == '0'
id: compare
run: |
if diff MARI/original.py temp-file.py; then
echo "::set-output name=changed::false"
else
echo "::set-output name=changed::true"
fi
- name: Rewrite original
if: steps.compare.outputs.changed == 'true' && steps.check_pr.outputs.exists == '0'
run: rm MARI/original.py && mv temp-file.py MARI/original.py
- name: Create Pull Request
if: steps.compare.outputs.changed == 'true' && steps.check_pr.outputs.exists == '0'
uses: peter-evans/create-pull-request@v5
with:
title: AUTOMATED_SCRIPT_UPDATE_PR
body: Manually compare the original to the autoreduction script, make necessary changes then merge
reviewers: keiranjprice101,Pasarus