Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to move diff generation to this repository #57

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-mix-${{matrix.pair.otp}}-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-
${{ runner.os }}-mix-${{matrix.pair.otp}}-

- name: Check Code Format
run: mix format --check-formatted
Expand All @@ -59,13 +59,3 @@ jobs:
name: Results
path: _build/test/lib/oapi_generator/*.xml
reporter: java-junit

diff:
name: "Generate Diff"
runs-on: ubuntu-latest
steps:
- name: Dispatch Workflow
env:
GH_TOKEN: ${{ secrets.DIFF_TOKEN }}
run: |
gh workflow run generate.yml --repo aj-foster/open-api-diffs --field ref=$GITHUB_HEAD_REF
73 changes: 73 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Generate

on:
push:
branches:
- main
pull_request: {}
workflow_dispatch:
inputs:
ref:
description: Ref of aj-foster/open-api-generator
required: true
type: string

permissions:
contents: write

jobs:
generate:
name: Generate Diff
runs-on: ubuntu-latest
steps:
- name: Setup Ref (Push)
if: github.event_name == 'pull_request'
run: |
echo "REF=main" >> $GITHUB_ENV

- name: Setup Ref (Pull Request)
if: github.event_name == 'pull_request'
run: |
echo "REF=$GITHUB_HEAD_REF" >> $GITHUB_ENV

- name: Setup Ref (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo "REF=${{ inputs.ref }}" >> $GITHUB_ENV

- name: Checkout (Diffs)
uses: actions/checkout@v4
with:
repository: "aj-foster/open-api-diffs"
ref: main
path: diffs

- name: Checkout (Generator)
uses: actions/checkout@v4
with:
repository: "aj-foster/open-api-generator"
path: generator

- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
otp-version: "27.0"
elixir-version: "1.17.1"

- name: Generate Code
run: |
cd diffs/
elixir generate.exs "$REF"

- name: Save Code
run: |
cd generator/
git checkout --orphan temporary-branch
git rm -rf .
mv ../diffs/output .
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add output/
git commit -m "Generated output for aj-foster/open-api-generator@$REF"
git tag -f "_diff/$REF"
git push --tags --force