forked from microsoft/finops-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
45 lines (45 loc) · 1.46 KB
/
opendata-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Open Data CI
on:
pull_request:
branches:
- dev
paths:
- 'src/open-data/*.csv'
- 'src/open-data/*.json'
permissions:
contents: write
pull-requests: write
statuses: write
jobs:
build:
runs-on: ubuntu-latest
env:
CI_COMMIT_MESSAGE: Generate PowerShell commands for open data
CI_COMMIT_AUTHOR: Open Data CI
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Set environment variable "commit-message"
run: echo "commit-message=$(git log -1 --pretty=format:'%s')" >> $GITHUB_ENV
- name: Set environment variable "commit-author"
run: echo "commit-author=$(git log -1 --pretty=format:'%an')" >> $GITHUB_ENV
- name: Set environment variable "is-auto-commit"
if: env.commit-message == env.CI_COMMIT_MESSAGE && env.commit-author == env.CI_COMMIT_AUTHOR
run: echo "is-auto-commit=true" >> $GITHUB_ENV
- name: Build Open Data
if: env.is-auto-commit == false
shell: pwsh
run: |
src/scripts/Build-OpenData.ps1 -PowerShell
if (git status --porcelain)
{
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "[email protected]"
git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
git push
}
- name: Test Open Data
shell: pwsh
run: |
src/scripts/Build-OpenData.ps1 -Test