Skip to content

Commit 44ac492

Browse files
committed
Automatically compile/generate output artifacts on push to main
1 parent d31921a commit 44ac492

File tree

2 files changed

+90
-34
lines changed

2 files changed

+90
-34
lines changed

.github/workflows/generate.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Generate Output
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
branches:
7+
- main
8+
9+
push:
10+
branches:
11+
- main
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: false
16+
17+
defaults:
18+
run:
19+
shell: bash
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
if: github.actor != 'elastic-machine'
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
with:
29+
token: ${{ secrets.PAT }}
30+
persist-credentials: true
31+
32+
- name: Setup Node 16.x
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: 16.x
36+
cache: npm
37+
cache-dependency-path: '**/package-lock.json'
38+
39+
- name: Setup Dependencies
40+
run: |
41+
make setup
42+
43+
- name: Generate Output
44+
run: |
45+
make compile
46+
make generate
47+
48+
- name: Check for Changed Files
49+
id: changes
50+
if: github.event_name == 'push'
51+
run: |
52+
if [ -n "$(git status --porcelain)" ]; then
53+
echo "has-changes=1" >> $GITHUB_OUTPUT
54+
fi
55+
56+
- name: Set Git Identity
57+
if: steps.changes.outputs.has-changes == '1'
58+
run: |-
59+
git config --global user.email "[email protected]"
60+
git config --global user.name "Elastic Machine"
61+
62+
- name: Push Output
63+
if: steps.changes.outputs.has-changes == '1'
64+
run: |
65+
cd ./output
66+
67+
git add -A
68+
git commit -m "Update specification output"
69+
70+
git status
71+
72+
git push
73+
74+
# For debugging purposes:
75+
# - name: Push Output
76+
# if: steps.changes.outputs.has-changes == '1'
77+
# env:
78+
# BRANCH_NAME: output_${{ github.run_id }}_${{ github.run_attempt }}
79+
# run: |
80+
# cd ./output
81+
82+
# git fetch
83+
# git switch main
84+
85+
# git add -A
86+
# git commit -m "Update specification output"
87+
88+
# git status
89+
90+
# git push origin HEAD:refs/heads/${{ env.BRANCH_NAME }}

.github/workflows/output-check.yml

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

0 commit comments

Comments
 (0)