Generate typescript and push to nulib/dcapi-types@staging #9
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 typescript and push to nulib/dcapi-types@staging | |
on: | |
pull_request_target: | |
types: | |
- closed | |
branches: | |
- "deploy/staging" | |
paths: | |
- "docs/docs/spec/data-types.yaml" | |
- ".github/flags/deploy-data-types" | |
workflow_dispatch: | |
jobs: | |
Push-To-Types-Repo-Staging: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
environment: staging | |
env: | |
TARGET_BRANCH: "staging" | |
TMP_SRCDIR: "./source" | |
TMP_DSTDIR: "./dest" | |
TYPES_REPO: "nulib/dcapi-types" | |
steps: | |
- run: | | |
echo PR with changes to datatypes.yml was merged into staging | |
- name: Checkout dc-api-v2 | |
uses: actions/checkout@v3 | |
with: | |
path: "${{ env.TMP_SRCDIR }}" | |
- uses: actions/setup-node@v3 | |
with: | |
cache-dependency-path: "${{ env.TMP_SRCDIR }}/node/package-lock.json" | |
node-version: 16.x | |
cache: "npm" | |
- name: get-npm-version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@main | |
with: | |
path: "${{ env.TMP_SRCDIR }}" | |
- name: Generate Typescript file | |
working-directory: "${{ env.TMP_SRCDIR }}" | |
run: | | |
npm ci | |
npx openapi-typescript docs/docs/spec/data-types.yaml --output schemas.ts | |
- name: Checkout dcapi-types | |
uses: actions/checkout@v3 | |
with: | |
path: ${{ env.TMP_DSTDIR }} | |
ref: ${{ env.TARGET_BRANCH }} | |
repository: ${{env.TYPES_REPO}} | |
- run: mv -f "${{ env.TMP_SRCDIR }}/schemas.ts" "${{ env.TMP_DSTDIR }}/schemas.ts" | |
shell: bash | |
- name: Set GitHub Deploy Key | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DCAPI_TYPES_DEPLOY_KEY }} | |
- working-directory: "${{ env.TMP_DSTDIR }}" | |
run: | | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
git add . | |
git commit -m "nulib/dc-api-v2 commit: $GITHUB_SHA, package.json version: ${{ steps.package-version.outputs.current-version}}" | |
git push origin HEAD | |
shell: bash |