Skip to content

Commit

Permalink
Automatically compile/generate output artifacts on push to main
Browse files Browse the repository at this point in the history
  • Loading branch information
flobernd committed Jul 13, 2023
1 parent d31921a commit 44ac492
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 34 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Generate Output

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

defaults:
run:
shell: bash

jobs:
build:
runs-on: ubuntu-latest
if: github.actor != 'elastic-machine'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
persist-credentials: true

- name: Setup Node 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
cache-dependency-path: '**/package-lock.json'

- name: Setup Dependencies
run: |
make setup
- name: Generate Output
run: |
make compile
make generate
- name: Check for Changed Files
id: changes
if: github.event_name == 'push'
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "has-changes=1" >> $GITHUB_OUTPUT
fi
- name: Set Git Identity
if: steps.changes.outputs.has-changes == '1'
run: |-
git config --global user.email "[email protected]"
git config --global user.name "Elastic Machine"
- name: Push Output
if: steps.changes.outputs.has-changes == '1'
run: |
cd ./output
git add -A
git commit -m "Update specification output"
git status
git push
# For debugging purposes:
# - name: Push Output
# if: steps.changes.outputs.has-changes == '1'
# env:
# BRANCH_NAME: output_${{ github.run_id }}_${{ github.run_attempt }}
# run: |
# cd ./output

# git fetch
# git switch main

# git add -A
# git commit -m "Update specification output"

# git status

# git push origin HEAD:refs/heads/${{ env.BRANCH_NAME }}
34 changes: 0 additions & 34 deletions .github/workflows/output-check.yml

This file was deleted.

0 comments on commit 44ac492

Please sign in to comment.