Merge pull request #257 from rimorin/multi_select #520
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: Ministry Mapper | |
env: | |
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }} | |
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }} | |
VITE_FIREBASE_DB_URL: ${{ secrets.VITE_FIREBASE_DB_URL }} | |
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }} | |
VITE_FIREBASE_BUCKET: ${{ secrets.VITE_FIREBASE_BUCKET }} | |
VITE_FIREBASE_SENDER_ID: ${{ secrets.VITE_FIREBASE_SENDER_ID }} | |
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }} | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN}} | |
on: | |
pull_request: | |
branches: | |
- staging | |
- master | |
push: | |
branches: | |
- staging | |
- master | |
jobs: | |
verify: | |
name: Verify Pull Request | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Notify pull request | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
payload: | | |
{ | |
"blocks" : [{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "*Initiating pull request verification*" | |
} | |
},{ | |
"type": "divider" | |
}], | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "${{ github.event.pull_request.title }}", | |
"value": "https://github.com/rimorin/ministry-mapper/pull/${{ github.event.number }}" | |
} | |
] | |
} | |
] | |
} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install dependencies | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
# 👆 check if cache-hit happened then do not execute npm ci | |
run: npm ci | |
- name: Check code formatting | |
run: npm run prettier | |
- name: passed formatting check | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
update-ts: ${{ steps.slack.outputs.ts }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "Code formatting", | |
"value": "Passed" | |
} | |
] | |
} | |
] | |
} | |
- name: Run application test cases | |
run: npm run test | |
- name: passed app test | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
update-ts: ${{ steps.slack.outputs.ts }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "Application tests", | |
"value": "Passed" | |
} | |
] | |
} | |
] | |
} | |
- name: Run application build | |
run: npm run build | |
- name: passed app build | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
update-ts: ${{ steps.slack.outputs.ts }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "Build test", | |
"value": "Passed" | |
} | |
] | |
} | |
] | |
} | |
- name: Notify passed verification | |
if: success() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
update-ts: ${{ steps.slack.outputs.ts }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "*Passed Verification*", | |
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
- name: Notify failed verification | |
if: failure() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
update-ts: ${{ steps.slack.outputs.ts }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "danger", | |
"fields": [ | |
{ | |
"title": "*Failed Verification*", | |
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
publish_chromatic: | |
name: Publish to chromatic | |
if: github.event_name == 'pull_request' && contains(github.ref, 'refs/heads/master') | |
needs: verify | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
run: npm ci | |
- name: Publish to Chromatic | |
uses: chromaui/action@v1 | |
with: | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
exitZeroOnChanges: true | |
staging_deployment: | |
name: Deploy to Staging | |
if: contains(github.event_name, 'push') && contains(github.ref, 'refs/heads/staging') | |
runs-on: ubuntu-latest | |
env: | |
HUSKY: 0 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies and build assets | |
run: npm ci && npm run build | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
directory: build | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: staging | |
- name: Failed deployment notification | |
if: failure() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "danger", | |
"fields": [ | |
{ | |
"title": "*Failed to deploy staging to Cloudflare Pages *", | |
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
- name: Success deployment notification | |
if: success() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "*Deployed staging to Cloudflare Pages*", | |
"value": ${{ steps.action.outputs.url }} | |
} | |
] | |
} | |
] | |
} | |
production_deployment: | |
name: Deploy to Production | |
if: contains(github.event_name, 'push') && contains(github.ref, 'refs/heads/master') | |
runs-on: ubuntu-latest | |
env: | |
HUSKY: 0 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies and build assets | |
run: npm ci && npm run build | |
- name: Semantic release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
run: npx semantic-release | |
- name: Publish to Cloudflare Pages | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | |
directory: build | |
gitHubToken: ${{ secrets.GITHUB_TOKEN }} | |
branch: master | |
- name: Failed deployment notification | |
if: failure() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "danger", | |
"fields": [ | |
{ | |
"title": "*Failed to deploy master to Cloudflare Pages *", | |
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
} | |
] | |
} | |
] | |
} | |
- name: Success deployment notification | |
if: success() | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }} | |
payload: | | |
{ | |
"attachments": [ | |
{ | |
"color": "good", | |
"fields": [ | |
{ | |
"title": "*Deployed production to Cloudflare Pages*", | |
"value": ${{ steps.action.outputs.url }} | |
} | |
] | |
} | |
] | |
} |