batch-example-2/.github/workflows/pull-request-target.yml

160 lines
5.1 KiB
YAML

name: target
on:
pull_request_target:
branches:
- main
jobs:
format:
runs-on: ubuntu-latest
outputs:
formatted: ${{ steps.has-changes.outputs.changes }}
steps:
- uses: RouxAntoine/checkout@v3.5.4
with:
token: ${{ secrets.BOT_TOKEN }}
# fetch-depth: '1'
- uses: actions/setup-node@v3
with:
node-version: '20.9.0'
- run: git checkout -b ${{ github.head_ref }}
- run: git pull origin ${{ github.head_ref }}
- uses: sigyl-actions/xml-format@v0.0.2
with:
folder: '.'
regex: ^.+\.(([aA][xX][mM][lL]))$
- uses: sigyl-actions/ftbatch-strip-dates@v0.0.1
with:
folder: './recipes'
regex: ^.+\.(([oO][xX][mM][lL])|([uU][xX][mM][lL])|([pP][xX][mM][lL]))$
- uses: sigyl-actions/xml-format@v0.0.2
with:
folder: './recipes'
regex: ^.+\.(([oO][xX][mM][lL])|([uU][xX][mM][lL])|([pP][xX][mM][lL]))$
- uses: sigyl-actions/check-for-changes@v1.0.1
id: has-changes
- uses: sigyl-actions/git-prep@v1.0.0
if: steps.has-changes.outputs.changes == 'true'
- run: git status
- name: commit if changed
if: steps.has-changes.outputs.changes == 'true'
run: |
git add -A
git commit -a -m "formatted"
git push origin HEAD
exit 1
document:
needs: format
if: needs.format.outputs.formatted != 'true'
runs-on: ubuntu-latest
outputs:
formatted: ${{ steps.has-changes.outputs.changes }}
steps:
- uses: RouxAntoine/checkout@v3.5.4
with:
token: ${{ secrets.BOT_TOKEN }}
# fetch-depth: '1'
- uses: actions/setup-node@v3
with:
node-version: '20.9.0'
- run: git checkout -b ${{ github.head_ref }}
- run: git pull origin ${{ github.head_ref }}
- run: rm -rf document
- run: mkdir document
- uses: https://sigyl.com:3001/actions/ft-view-screen-document@main
name: document ft-view
with:
display-exclude-file: BatchImport_zone10_hmi_restored.xml
global-exclude-file: BatchImport_Global_zone10_hmi_restored.xml
display-folder: displays
global-folder: global objects
folder: ft-view-screens
- uses: https://sigyl.com:3001/actions/document-phases@main
name: document batch
with:
document: document
model: equipment-model.axml
opc: equipment-model.json
recipes: recipes
- uses: sigyl-actions/check-for-changes@v1.0.1
id: has-changes
- uses: sigyl-actions/git-prep@v1.0.0
if: steps.has-changes.outputs.changes == 'true'
- run: git status
- name: commit if changed
if: steps.has-changes.outputs.changes == 'true'
run: |
git add -A
git commit -a -m "documented ${{ github.event.head_commit.message }}"
git push origin HEAD
exit 1
schema:
runs-on: ubuntu-latest
needs: document
if: needs.document.outputs.formatted != 'true'
outputs:
result: ${{ steps.schema.outputs.result }}
error: ${{ steps.schema.outputs.error }}
schema: ./.github/schemas/AreaModel.xsd
steps:
- uses: RouxAntoine/checkout@v3.5.4
with:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: '1'
- uses: actions/setup-node@v3
with:
node-version: '20'
- id: pwd
run: |
echo -n pwd= >> $GITHUB_OUTPUT
pwd >> $GITHUB_OUTPUT
- uses: sigyl-actions/xml-schema@v0.0.1
id: schema
# continue-on-error: true
with:
schema_path: ${{ steps.pwd.outputs.pwd}}
folder: '.'
regex: ^.+\.(([aA][xX][mM][lL]))$
xsd: ./.github/schemas/AreaModel.xsd
# master recipes isn't a valid schema!
#- uses: sigyl-actions/xml-schema@main
# with:
# schema_path: ${{ steps.pwd.outputs.pwd}}
# folder: './recipes'
# regex: ^.+\.(([oO][xX][mM][lL])|([uU][xX][mM][lL])|([pP][xX][mM][lL]))$
# xsd: ./.github/schemas/MasterRecipe.xsd
review:
runs-on: ubuntu-latest
needs:
- schema
steps:
- name: json
run: echo $JSON
env:
JSON: ${{ toJSON(needs) }}
- uses: RouxAntoine/checkout@v3.5.4
with:
fetch-depth: '1'
- uses: actions/setup-node@v3
with:
node-version: '20'
- uses: sigyl-actions/gitea-pr-review@v0.0.1
if: ${{ needs.schema.outputs.error != 'true' }}
with:
token: ${{ secrets.BOT_TOKEN }}
id: ${{ github.event.number }}
description: 'Schema checks pass'
body: |
pull changes
event: APPROVED
- uses: sigyl-actions/gitea-pr-review-xml-schema@v0.0.1
if: ${{ needs.schema.outputs.error == 'true' }}
with:
token: ${{ secrets.BOT_TOKEN }}
id: ${{ github.event.number }}
errors: ${{ needs.schema.outputs.result }}
body: |
# schema checks failed
event: REQUEST_CHANGES