1- name : Test run v2
1+ # Copyright (c) Microsoft Corporation. All rights reserved.
2+ # Licensed under the MIT License.
3+ # This is a basic workflow to help you get started with Actions
24
5+ name : " Metadata Changes"
6+ # Controls when the action will run. Triggers the workflow on push or pull request
7+ # events but only for the master branch
38on :
49 workflow_dispatch :
10+ pull_request :
11+ types : [opened, synchronize, reopened, closed]
12+ branches :
13+ - dev
514
15+ # A workflow run is made up of one or more jobs that can run sequentially or in parallel
616jobs :
7- test :
8- runs-on : ubuntu-18.04
17+ CheckForMetadataChanges :
18+ # The type of runner that the job will run on
19+ runs-on : ubuntu-latest
20+ if : github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed')
21+ # Steps represent a sequence of tasks that will be executed as part of the job
922 steps :
10- - name : Show environment v2
11- run : env | grep ^GITHUB
12- - name : Show ref v2
13- run : echo "===============> Version from $GITHUB_REF"
23+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24+ - name : Checkout
25+ uses : actions/checkout@v4
26+ with :
27+ ref : ${{ github.event.pull_request.head.sha }}
28+
29+
30+ # Check if error report exists
31+ - name : Check file existence
32+ id : check_files
33+ uses : andstor/file-existence-action@v3
34+ with :
35+ files : " docs/OpenApiInfo/v1.0/openAPIErrors.csv"
36+
37+ # If it exists then add a warning to comment section of the PR
38+ - name : File exists
39+ if : steps.check_files.outputs.files_exists == 'true'
40+ uses : actions/github-script@v7
41+ with :
42+ script : |
43+ const name = 'OpenApiChecks';
44+ const body = '**Changes in metadata detected :bangbang:** :warning:\n Please have a look at the metadata changes report in `docs/OpenApiInfo/v1.0/openAPIErrors.csv`\nThis action is important before merging :pleading_face:';
45+
46+ await github.rest.issues.createComment({
47+ issue_number : context.issue.number,
48+ owner : context.repo.owner,
49+ repo : context.repo.repo,
50+ body : body
51+ })
52+
53+ # [0] https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
54+ # [1] https://hub.github.com/hub-pull-request.1.html
55+ # https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token
0 commit comments