Lag typescript typer fra json og publiser #874
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: Lag typescript typer fra json og publiser | |
on: | |
workflow_dispatch: | |
inputs: | |
artifactId: | |
required: true | |
type: string | |
appNavn: | |
required: true | |
type: string | |
with-enums: | |
required: false | |
type: boolean | |
default: false | |
description: enum flag in openapi-typescript command | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} | |
SKIP_YARN_COREPACK_CHECK: true | |
permissions: | |
contents: write | |
id-token: write | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
registry-url: https://npm.pkg.github.com | |
cache: yarn | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Last ned artifact | |
run: | | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.READER_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-o artifact.zip \ | |
https://api.github.com/repos/navikt/aap-${{ inputs.appNavn }}/actions/artifacts/${{ inputs.artifactId }}/zip | |
- name: Unzip artifact | |
run: | | |
unzip -o artifact.zip -d ./packages/aap-${{ inputs.appNavn }}-typescript-types | |
- name: install dependencies | |
run: | | |
yarn install --immutable | |
- name: generer schema fra json med enums | |
if: ${{ inputs.with-enums == true }} | |
run: | | |
yarn openapi-typescript ./packages/aap-${{ inputs.appNavn }}-typescript-types/openapi.json -o ./packages/aap-${{ inputs.appNavn }}-typescript-types/schema.ts --enum | |
- name: generer schema fra json | |
if: ${{ inputs.with-enums != true }} | |
run: | | |
yarn openapi-typescript ./packages/aap-${{ inputs.appNavn }}-typescript-types/openapi.json -o ./packages/aap-${{ inputs.appNavn }}-typescript-types/schema.d.ts | |
# - name: TODO: sammenlign schemas og se om det må publiseres ny verson | |
# run: hei | |
- name: bygg | |
run: | | |
yarn run build | |
- name: lag changeset-fil | |
run: | | |
echo '---' > .changeset/test.md | |
echo '"@navikt/aap-${{ inputs.appNavn }}-typescript-types": patch' >> .changeset/test.md | |
echo '---' >> .changeset/test.md | |
echo '' >> .changeset/test.md | |
echo 'ny versjon av typescript typer' >> .changeset/test.md | |
- name: changeset version og commit | |
run: | | |
yarn changeset version | |
git config user.email "[email protected]" | |
git config user.name "Team Aap" | |
git add ./packages/aap-${{ inputs.appnavn }}-typescript-types/ | |
git commit -m ":label: genererte backendtyper" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Create a .npmrc file for the github package repository" | |
uses: "FerLuisxd/create-npmrc@3" | |
with: | |
org_name: "navikt" | |
env: | |
AUTH_TOKEN: "${{secrets.GITHUB_TOKEN}}" | |
- name: Publish ublish to NPM | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
publish: yarn changeset publish | |
createGithubReleases: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} |