Update use-reuseble-file.yml #35
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: Website Deployment | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
# Assigns an ID 'cache' to reference this step later | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
# The 'if' condition checks if the 'cache-hit' output from the previous 'cache' step is not 'true' | |
# If the cache was not found, the dependencies will be installed | |
if: steps.cache.output.cache-hit != 'true' | |
run: npm ci | |
- name: Lint code | |
run: npm run lint | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
# Assigns an ID 'cache' to reference this step later | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
# The 'if' condition checks if the 'cache-hit' output from the previous 'cache' step is not 'true' | |
# If the cache was not found, the dependencies will be installed | |
if: steps.cache.output.cache-hit != 'true' | |
run: npm ci | |
- name: Test code | |
# Assigns an ID to this step, which allows referencing it in later steps | |
id: run-tests | |
run: npm run test | |
- name: Upload test report | |
# The if condition ensures this step runs only if the workflow is in a failed state | |
if: failure() && steps.run-tests.outcome == 'failure' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-report | |
path: test.json | |
build: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get code | |
uses: actions/checkout@v3 | |
- name: Cache dependencies | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Build website | |
id: build-website | |
run: npm run build | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist-files | |
path: dist | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist-files | |
- name: Output contents | |
run: ls | |
- name: Deploy | |
run: echo "Deploying..." | |
report: | |
needs: [lint, deploy] | |
if: failure() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Output information | |
run: | | |
echo "Something went wrong" | |
echo "${{ GITHUB }}" |