Update README.md #25
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, Lint, Test, SonarCloud Analysis, and Deploy to Netlify | |
on: | |
push: | |
branches: [v1.1-api] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "16" | |
- name: Cache Dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Dependencies | |
run: npm install | |
- name: Lint | |
run: npx eslint . --ext .js,.jsx,.ts,.tsx | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
env: | |
GITHUB_TOKEN: ${{ secrets.GHCR_PAT }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
- name: Run Tests | |
run: npm test | |
- name: Build | |
run: npm run build | |
- name: Build Docker Image | |
run: docker build -t ghcr.io/romanprotoliuk/yoga-app-front-end:$GITHUB_SHA . | |
- name: Login to GitHub Container Registry | |
run: echo ${{ secrets.GHCR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Push Docker Image to GitHub Packages | |
run: docker push ghcr.io/romanprotoliuk/yoga-app-front-end:$GITHUB_SHA | |
- name: Deploy to Netlify | |
if: github.ref == 'refs/heads/v1.1-api' && github.event_name == 'push' | |
uses: netlify/actions/cli@master | |
env: | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
with: | |
args: deploy --dir=build --prod |