.github/workflows/publish.yml
name: Publish npm package and docker image
on:
push:
tags:
- 'v*.*.*'
jobs:
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- name: Install dependencies
run: npm install
- name: Publish to npm
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
- name: Generate Docker tags
id: dockermeta
uses: crazy-max/ghaction-docker-meta@v2
with:
images: jormaechea/open-api-mocker
tags: |
type=semver,pattern={{version}}
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: jormaechea
password: ${{ secrets.DOCKER_TOKEN }}
- name: Publish to Docker Hub
uses: docker/build-push-action@v2
with:
build-args:
open_api_mocker_version=${{ steps.dockermeta.outputs.version }}
context: .
push: true
tags: ${{ steps.dockermeta.outputs.tags }}