Skip to content

Commit e418c3e

Browse files
committed
Added workflow for metadata changes
1 parent 34f0d7d commit e418c3e

File tree

4 files changed

+50
-49
lines changed

4 files changed

+50
-49
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
- template: ./common-templates/install-tools.yml
4444
- template: ./common-templates/security-pre-checks.yml
4545

46-
- template: ./generation-templates/check-openapi-errors.yml
47-
4846
- template: ./generation-templates/authentication-module.yml
4947
parameters:
5048
Test: ${{ parameters.Test }}
Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,55 @@
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
38
on:
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
616
jobs:
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

tools/OpenApiInfoGenerator/OpenApiInfoGenerator/OpenApiChanges.ps1

Lines changed: 0 additions & 39 deletions
This file was deleted.

tools/OpenApiInfoGenerator/OpenApiInfoGenerator/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private static void CompareOpenApiInfo(string version, IList<Model> openApiInfoM
4040
var errorPath = openApiInfoPath != null ? Path.Combine(openApiInfoPath, openApiFileError) : null;
4141
if (errorPath != null && File.Exists(errorPath))
4242
{
43-
File.WriteAllText(errorPath, string.Empty);
43+
File.Delete(errorPath);
4444
}
4545
if (openApiPath != null)
4646
{

0 commit comments

Comments
 (0)