generate-all #3834
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
name: generate-all | |
on: | |
schedule: | |
- cron: '15 */4 * * *' | |
push: | |
branches: | |
- 'develop' | |
- 'feature/**' | |
- 'chore/**' | |
- 'bugfix/**' | |
- 'story/**' | |
workflow_dispatch: | |
jobs: | |
prerequisite: | |
name: Prerequisite for Generation | |
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/feature') || startsWith(github.ref, 'refs/heads/chore') || startsWith(github.ref, 'refs/heads/bugfix') || startsWith(github.ref, 'refs/heads/story') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Prerequisite | |
run: | | |
echo Prerequisites passed! | |
generate-bmcapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc/download_spec | |
package-name: bmcapi | |
generate-rancherapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/rancher/download_spec | |
package-name: ranchersolutionapi | |
generate-networkapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/networks/download_spec | |
package-name: networkapi | |
generate-ipapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/ips/download_spec | |
package-name: ipapi | |
generate-auditapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc-audit/download_spec | |
package-name: auditapi | |
generate-tagapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/tags/download_spec | |
package-name: tagapi | |
generate-billingapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc-billing/download_spec | |
package-name: billingapi | |
generate-networkstorageapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/network-storage/download_spec | |
package-name: networkstorageapi | |
generate-locationapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/bmc-location/download_spec | |
package-name: locationapi | |
generate-invoicingapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/invoicing/download_spec | |
package-name: invoicingapi | |
generate-paymentsapi: | |
needs: prerequisite | |
uses: ./.github/workflows/_generate.yml | |
with: | |
spec-link: https://developers.phoenixnap.com/portals/api/sites/phoenixnap-prod-developerportal/liveportal/apis/payments/download_spec | |
package-name: paymentsapi | |
# Push generated code | |
push-changes: | |
name: Push Changes | |
runs-on: ubuntu-latest | |
needs: | |
- generate-bmcapi | |
- generate-rancherapi | |
- generate-networkapi | |
- generate-ipapi | |
- generate-auditapi | |
- generate-tagapi | |
- generate-billingapi | |
- generate-networkstorageapi | |
- generate-locationapi | |
- generate-invoicingapi | |
- generate-paymentsapi | |
outputs: | |
CHANGES_FOUND: ${{ steps.commit-step.outputs.CHANGES_FOUND }} | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
# 2nd part of cleanup. | |
# Checking out the repository will include all the dirty files as well, | |
# so here we need to delete the existing modules and keep only the artifacts | |
# that were generated. | |
- name: Clean up modules | |
run: | | |
rm -r ./bmcapi \ | |
./ranchersolutionapi \ | |
./networkapi \ | |
./ipapi \ | |
./auditapi \ | |
./tagapi \ | |
./billingapi \ | |
./networkstorageapi \ | |
./locationapi \ | |
./invoicingapi \ | |
./paymentsapi | |
- name: Download Artifacts | |
uses: actions/download-artifact@v3 | |
- name: Move spec files | |
run: | | |
find . -type f -name "*.spec.yaml" -not -path "./specs/*" -print0 | xargs -0 mv -ft ./specs/ | |
- id: commit-step | |
name: Add and Commit files | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add -A | |
# Uses git status to check whether changes are present. | |
if test "$(git status --porcelain=v1 2>/dev/null | wc -l)" -gt "0" ; | |
then | |
git commit -m "Add changes"; | |
echo "CHANGES_FOUND=true" >> "$GITHUB_OUTPUT"; | |
else | |
echo No changes found; | |
fi | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
validate-all: | |
if: ${{ needs.push-changes.outputs.CHANGES_FOUND }} | |
needs: | |
- push-changes | |
uses: ./.github/workflows/validate-all.yml |