fix: select community image #376
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: Workflow | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
build-project: #First Job is to check the code formatting, linting and build the project. | |
if: github.event.pull_request.draft == false | |
name: Run Formatting Checks and Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- uses: actions/cache@v4 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- if: ${{ steps.npm-cache.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
- name: Install Dependencies | |
run: npm ci | |
- name: Code Formatting Check #Runs Prettier Script | |
run: npm run prettier | |
- name: Linting Check #Runs ESLint Script | |
run: npm run lint | |
- name: Test #Runs Jest Script | |
run: npm run coverage | |
- name: Upload coverage to Codecov #Uploads the coverage report to Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} | |
- name: Build #Build the project | |
env: | |
MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
GRAPHQL_REF: ${{ secrets.GRAPHQL_REF }} | |
run: npm run build | |
- name: Check Build Status | |
run: | | |
if [ $? -eq 0 ]; then | |
echo "Build successful!🎉" | |
else | |
echo "Build failed!" | |
exit 1 | |
fi | |
chromatic-deployment: #Second Job is to deploy the project to Chromatic | |
if: github.event.pull_request.draft == false | |
name: Deploy Storybook to Chromatic | |
runs-on: ubuntu-latest # Operating System | |
needs: build-project #Depends on the build-project job to be completed | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- name: Install dependencies | |
run: npm install | |
# 👇 Adds Chromatic as a step in the workflow | |
- name: Publish to Chromatic | |
uses: chromaui/action@latest | |
# Chromatic GitHub Action options | |
with: | |
# 👇 Chromatic projectToken, refer to the manage page to obtain it. | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |