Updated gitignore #616
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: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-dependencies | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- name: Installing dependencies | |
run: npm install -g prettier eslint && npm install | |
- name: Linting | |
run: npm run lint | |
- name: Testing | |
run: npm run test | |
- 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 }} | |
- name: Get Package Version | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@master | |
- 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 # Required due to the weg Git works, without it this action won't be able to find any or the correct tags | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '14' | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-dependencies | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
- 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 }} |