actions: add workflow_dispatch #41
This file contains hidden or 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: Update client libraries | |
on: | |
push: | |
workflow_dispatch: | |
# schedule: | |
# - cron: "0 0 * * 1" | |
jobs: | |
generate: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- language: ts | |
copy: "/bin/cp -rf ./clients/ts/. h1-client-ts" | |
directory: "h1-client-ts" | |
repository: "hyperonecom/h1-client-js" | |
build: "yarn" | |
- language: go | |
copy: "/bin/cp -rf ./clients/go/. h1-client-go" | |
directory: "h1-client-go" | |
repository: "hyperonecom/h1-client-go" | |
build: "go build -o temporary_build && rm temporary_build" | |
- language: python | |
copy: "/bin/cp -rf ./clients/python/. h1-client-python" | |
directory: "h1-client-python" | |
repository: "hyperonecom/h1-client-python" | |
build: "pip install -e ." | |
runs-on: ubuntu-latest | |
env: | |
GO_POST_PROCESS_FILE: "/usr/local/bin/gofmt -w" | |
LANGUAGE: "${{ matrix.language }}" | |
steps: | |
- name: Checkout generator repository | |
uses: actions/checkout@v1 | |
- name: Download OpenAPI spec file | |
run: | | |
sudo apt install wget | |
wget -O openapi.json https://api.hyperone.com/v2/openapi.json | |
- name: Set up Node 14.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "14.x" | |
- name: Set up Go 1.14.x | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.14.x | |
- name: Set up Python 3.6 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.6 | |
- name: Configure github credentials | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
- name: Copy passport file to home directory | |
run: | | |
mkdir -p ~/.h1 | |
echo "$PASSPORT_FILE" > ~/.h1/passport.json | |
env: | |
PASSPORT_FILE: ${{ secrets.PASSPORT_FILE }} | |
- name: Install dependencies | |
run: yarn | |
- name: Generate and test client | |
run: yarn start "$LANGUAGE" | |
- name: Test building client | |
run: "${{ matrix.build }}" | |
working-directory: "./clients/${{ matrix.language }}" | |
- name: Checkout Client repo | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
repository: "${{ matrix.repository }}" | |
path: "${{ matrix.directory }}" | |
- name: Copy client | |
run: "${{ matrix.copy }}" | |
- name: Commit client | |
run: | | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Update $(date)" | |
working-directory: "${{ matrix.directory }}" | |
- name: Push client | |
uses: ad-m/github-push-action@master | |
if: "${{ success() && github.ref == 'refs/heads/master' }}" | |
with: | |
github_token: ${{ secrets.PUSH_TOKEN }} | |
directory: "${{ matrix.directory }}" | |
repository: "${{ matrix.repository }}" |