Update jest monorepo #628
Workflow file for this run
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: CI/CD | |
on: [push, pull_request] | |
jobs: | |
CI: | |
runs-on: ubuntu-latest | |
outputs: | |
current-version: ${{ steps.package-version.outputs.current-version }} | |
latest-tag: ${{ steps.latest-tag.outputs.tag }} | |
new-version: ${{ toJSON(steps.package-version.outputs.current-version != steps.latest-tag.outputs.tag) }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: "npm" | |
- name: Installing dependencies | |
run: npm install | |
- name: Linting | |
run: npm run lint | |
- name: Testing | |
run: npm run test | |
- name: Building | |
run: npm run build | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
with: | |
projectBaseDir: packages/svelte-reveal | |
- name: Get Package Version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
with: | |
path: "packages/svelte-reveal" | |
- name: "Get Latest Tag" | |
id: latest-tag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
- name: Print CI output | |
run: | | |
echo "Current version: ${{ steps.package-version.outputs.current-version }}" \ | |
echo "Latest tag: ${{ steps.latest-tag.outputs.tag }}" \ | |
echo "New version: ${{ toJSON(steps.package-version.outputs.current-version != steps.latest-tag.outputs.tag) }}" | |
CD: | |
needs: [CI] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && fromJSON(needs.CI.outputs.new-version) | |
steps: | |
- name: Print CI output | |
run: | | |
echo "Current version: ${{ needs.CI.outputs.current-version }}" \ | |
echo "Latest tag: ${{ needs.CI.outputs.latest-tag }}" \ | |
echo "New version: ${{ fromJSON(needs.CI.outputs.new-version) }}" | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
cache: "npm" | |
- name: Extract release notes | |
id: extract-release-notes | |
uses: ffurrer2/extract-release-notes@v1 | |
- name: Create new release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.CI.outputs.current-version }} | |
release_name: ${{ needs.CI.outputs.current-version }} | |
draft: false | |
prerelease: false | |
body: ${{ steps.extract-release-notes.outputs.release_notes }} | |
# DOCKER | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker image | |
id: docker_build | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/svelte-reveal:latest | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
- name: Installing dependencies | |
run: npm install | |
- name: Publish package on NPM | |
uses: JS-DevTools/npm-publish@v1 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
package: ./packages/svelte-reveal/package.json |