自動でプッシュまで行う #3
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: build and publish package | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- 'src/**' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: https://npm.pkg.github.com/ | |
- name: Install openapi-generator-cli | |
run: npm install -g @openapitools/openapi-generator-cli | |
- name: Generate src | |
run: openapi-generator-cli generate -i ./docs/cuculus-openapi.yaml -g typescript-fetch -o ./src -c ./config.json | |
- name: Commit and push | |
run: | | |
git remote set-url origin https://github-actions:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY} | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git add src/ | |
git commit -m "$(date +'%Y-%m-%d') Update" | |
git push origin HEAD:${GITHUB_REF} | |
- name: Package install | |
run: npm install | |
- name: Publish package | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |