-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move diff generation workflow to this repository
This avoids issues with GitHub token permissions across pull requests from forks
- Loading branch information
Showing
2 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |