Skip to content

Commit 30c9880

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

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+
push:
5+
branches:
6+
- main
7+
8+
# For debugging purposes:
9+
# pull_request:
10+
# types: [opened, synchronize, reopened]
11+
# branches:
12+
# - main
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: false
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
if: github.repository_owner == 'elastic' && github.actor != 'elasticmachine'
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
with:
30+
token: ${{ secrets.PAT }}
31+
persist-credentials: true
32+
33+
- name: Setup Node 16.x
34+
uses: actions/setup-node@v3
35+
with:
36+
node-version: 16.x
37+
cache: npm
38+
cache-dependency-path: '**/package-lock.json'
39+
40+
- name: Setup Dependencies
41+
run: |
42+
make setup
43+
44+
- name: Generate Output
45+
run: |
46+
make compile
47+
make generate
48+
49+
- name: Check for Changed Files
50+
id: changes
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)