Skip to content

Import API spec

Import API spec #3

name: Import API spec
on:
workflow_dispatch:
jobs:
create-files:
runs-on: ubuntu-latest
outputs:
filename: ${{ steps.makefile.outputs.filename }}
steps:
- id: makefile
run: |
echo "my-data" > output.txt
echo "filename=output.txt" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: output-file
path: output.txt
update-branch:
needs: create-files
runs-on: ubuntu-latest
steps:
- name: Verify branch context
run: |
echo "Triggered from ref: ${{ github.ref }}"
echo "Branch name: ${{ github.ref_name }}"
if [[ "${{ github.ref_type }}" != "branch" ]]; then
echo "❌ This workflow must be triggered on a branch."
exit 1
fi
- name: Checkout current branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: output-file
- name: Commit and push changes
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add output.txt
git commit -m "Update current branch with generated file" || echo "No changes"
git push origin HEAD:${{ github.ref_name }}