jiahaog/nativefier

View on GitHub
.github/workflows/publish.yml

Summary

Maintainability
Test Coverage
name: publish
on:
  release:
    types:
      - created
jobs:
  playwright:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2 # Setup .npmrc file to publish to npm
        with:
          node-version: '20' # Align the version of Node here with ci.yml.
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci --no-fund # Will also (via `prepare` hook): 1. install ./app, 2. build
      - run: npm run test:playwright
        timeout-minutes: 5

  build:
    needs: playwright
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2 # Setup .npmrc file to publish to npm
        with:
          node-version: '20' # Align the version of Node here with ci.yml.
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci --no-fund # Will also (via `prepare` hook): 1. install ./app, 2. build
      - run: npm run test:noplaywright
      - run: npm run lint
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

  docker:
    needs: [ playwright, build ]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Build Docker image
        run: docker build . --file Dockerfile --tag "nativefier/nativefier:latest"
      - name: Login to Docker Hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Tag and push Docker image
        run: |
          docker tag "nativefier/nativefier:latest" "nativefier/nativefier:${GITHUB_REF_NAME}"
          docker push "nativefier/nativefier:latest"
          docker push "nativefier/nativefier:${GITHUB_REF_NAME}"