Skip to content

Commit

Permalink
chore: clean up GitHub Actions workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Nov 17, 2023
1 parent 261978e commit 866421f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
File renamed without changes.
12 changes: 9 additions & 3 deletions script/onboard_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ sed -i '' "s/__PACKAGE_NAME__/${service_name}/g" Makefile.${service_name}
sed -i '' "s|__SPEC_BASE_URL__|${spec_url}|g" Makefile.${service_name}
sed -i '' "s|__SPEC_ROOT_FILE__|${spec_root_file}|g" Makefile.${service_name}

mkdir -p spec/services/${service_name}
mkdir -p templates/services/${service_name}
mkdir -p config/services/${service_name}
cp templates/.github/workflows/sync.yaml .github/workflows/sync-${service_name}.yaml
sed -i '' "s/__PACKAGE_NAME__/${service_name}/g" .github/workflows/sync-${service_name}.yaml

cp templates/.github/workflows/test.yaml .github/workflows/test-${service_name}.yaml
sed -i '' "s/__PACKAGE_NAME__/${service_name}/g" .github/workflows/test-${service_name}.yaml

mkdir -p spec/services/${service_name} && touch spec/services/${service_name}/.keep
mkdir -p templates/services/${service_name} && touch templates/services/${service_name}/.keep
mkdir -p patches/services/${service_name} && touch patches/services/${service_name}/.keep

make -f Makefile.${service_name} all
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Sync
name: Sync __PACKAGE_NAME__ spec

on:
workflow_dispatch:

jobs:
sync:
sync__PACKAGE_NAME__:
strategy:
matrix:
go-version: [1.19.x]
Expand All @@ -28,22 +28,22 @@ jobs:
- name: Fetch latest spec
id: fetch
run: |
make fetch
git add spec/oas3.fetched
make -f Makefile.__PACKAGE_NAME__ fetch
git add spec/services/__PACKAGE_NAME__
echo `git commit -m 'sync: fetch ${{ steps.date.outputs.date }} spec and apply patches'`
- name: Apply spec patches
id: patch
if: ${{ always() && steps.fetch.conclusion == 'success' }}
run: |
make patch
git add spec/oas3.patched
make -f Makefile.__PACKAGE_NAME__ patch
git add spec/services/__PACKAGE_NAME__
echo `git commit -m 'sync: patch spec with ${{ steps.date.outputs.date }} spec'`
- name: Generate code
id: generate
if: ${{ always() && steps.patch.conclusion == 'success' }}
run: |
make generate
git add api docs metal API.md go.mod go.sum
make -f Makefile.__PACKAGE_NAME__ generate
git add services/__PACKAGE_NAME__
echo `git commit -m 'sync: generate client with ${{ steps.date.outputs.date }} spec'`
- name: Create Pull Request
id: cpr
Expand All @@ -54,9 +54,9 @@ jobs:
branch-suffix: timestamp
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
commit-message: "sync: uncommitted changes detected when opening PR"
title: "feat: API Sync by GitHub Action (${{ steps.date.outputs.date }})"
title: "feat: API Sync by GitHub Action for @${{ github.event.sender }}"
body: |
This API Sync PR was automated through [GitHub Actions workflow_displatch](https://github.com/equinix-labs/metal-go/actions?query=event%3Aworkflow_dispatch)
This API Sync PR was triggered by @${{ github.event.sender }} through [GitHub Actions workflow_displatch](https://github.com/equinix/equinix-sdk-go/actions?query=event%3Aworkflow_dispatch)
on ${{ steps.date.outputs.date }}.
* latest Swagger is fetched
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
on: [push, pull_request]
name: Test
name: Test __PACKAGE_NAME__ PR

on:
push:
paths:
- **/__PACKAGE_NAME__/**
pull_request:
paths:
- **/__PACKAGE_NAME__/**

jobs:
test:
strategy:
Expand All @@ -15,9 +23,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
- name: Verify Patches
run: make patch
run: make -f Makefile.__PACKAGE_NAME__ patch
- name: Generate
run: |
make generate
make -f Makefile.__PACKAGE_NAME__ generate
# Expect all changes to be accounted for
! git status --porcelain | grep .

0 comments on commit 866421f

Please sign in to comment.