fixed file #8
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: CD Pipeline | |
on: | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v2 | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Run unit tests | |
run: npm test | |
- name: Generate build | |
run: npm run build --if-present | |
- name: Share artifact inside workflow | |
uses: actions/upload-artifact@v1 | |
with: | |
name: react-github-actions-build | |
path: dist | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
# When application is successfully tested and build has been generated | |
# Then we can start with deployment | |
needs: build | |
steps: | |
# Download previously shared build | |
- name: Get artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: react-github-actions-build | |
path: ./dist | |
- name: check the files to deploy | |
run: cd dist && ls | |
- name: Deploy to gh-pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist | |
user_name: 'github-actions[bot]' | |
user_email: 'github-actions[bot]@users.noreply.github.com' | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
# We specify that deploys needs to | |
# finish before we create a release | |
needs: deploy | |
steps: | |
# Download previously shared build | |
- name: Get artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: react-github-actions-build | |
# Zip the build using external action | |
- name: Zip build | |
uses: thedoctor0/zip-release@master | |
with: | |
filename: react-github-actions-release-build.zip | |
path: react-github-actions-build | |
# Upload as an artifact of the current workflow | |
- name: Upload build zip artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: react-github-actions-release-build.zip | |
path: react-github-actions-release-build.zip | |
# Make official GitHub release which will trigger | |
# sending the mail with link for access | |
- name: Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: react-github-actions-release-build.zip | |
body: https://navtej927.github.io/cicd-github-pages/ | |
token: ${{ secrets.GITHUB_TOKEN }} |