forked from deriv-com/sinbad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request deriv-com#130 from yaswanth-deriv/yaswanth/setup-g…
…ithub-actions-sindabad build: to migrate from circleci to github workflows
- Loading branch information
Showing
9 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: Build | ||
description: Build for release | ||
runs: | ||
steps: | ||
- name: Building Application | ||
run: npm run build | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Notify slack | ||
description: Notify Slack | ||
inputs: | ||
SLACK_WEBHOOK: | ||
description: 'Slack webhook URL' | ||
required: true | ||
status: | ||
description: 'Job status' | ||
required: true | ||
release_type: | ||
description: 'Release type' | ||
required: true | ||
version: | ||
description: 'Version' | ||
required: true | ||
default: 'N/A' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Send Slack Notification on Success | ||
if: inputs.status == 'success' | ||
run: |- | ||
curl -X POST -H 'Content-type: application/json' \ | ||
--data '{ | ||
"text": "'"${{ inputs.release_type }}"' Release succeeded for Sindabad with version *'"${{ inputs.version }}"'*" | ||
}' \ | ||
${{ inputs.SLACK_WEBHOOK_URL }} | ||
shell: bash | ||
- name: Send Slack Notification on Failure | ||
if: inputs.status == 'failure' | ||
run: |- | ||
curl -X POST -H 'Content-type: application/json' \ | ||
--data '{ | ||
"text": "'"${{ inputs.release_type }}"' Release failed for Sindabad with version *'"${{ inputs.version }}"'*" | ||
}' \ | ||
${{ inputs.SLACK_WEBHOOK_URL }} | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: npm_install_from_cache | ||
description: Install npm packages from cache | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Cache node modules | ||
id: cache-nodemodules | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node_modules-${{ hashFiles('./package-lock.json') }} | ||
- name: Install npm dependencies | ||
if: steps.cache-nodemodules.outputs.cache-hit != 'true' | ||
run: |- | ||
npm ci | ||
npm run format | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: publish_to_pages_production | ||
description: Publish to cloudflare pages (production) | ||
inputs: | ||
CLOUDFLARE_ACCOUNT_ID: | ||
description: 'Cloudflare account id' | ||
required: true | ||
CLOUDFLARE_API_TOKEN: | ||
description: 'Cloudflare token' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Publish to cloudflare pages (production) | ||
env: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} | ||
run: | | ||
npm i [email protected] | ||
cd packages/core | ||
npx wrangler pages publish . --project-name=sinbad-pages --branch=main | ||
echo "New website - http://cf-pages-sinbad.deriv.com" | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: publish_to_pages_staging | ||
description: Publish to cloudflare pages (staging) | ||
inputs: | ||
CLOUDFLARE_ACCOUNT_ID: | ||
description: 'Cloudflare account id' | ||
required: true | ||
CLOUDFLARE_API_TOKEN: | ||
description: 'Cloudflare token' | ||
required: true | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Publish to cloudflare pages (staging) | ||
env: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ inputs.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ inputs.CLOUDFLARE_API_TOKEN }} | ||
run: | | ||
npm i [email protected] | ||
cd public | ||
npx wrangler pages publish . --project-name=sinbad-pages --branch=staging | ||
echo "New staging website - http://staging.cf-pages-sinbad.deriv.com" | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Versioning | ||
description: Versioning | ||
inputs: | ||
RELEASE_TYPE: | ||
description: Release Type | ||
required: false | ||
outputs: | ||
version: | ||
description: Version | ||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: Set Version | ||
id: set_version | ||
run: | | ||
current_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
version="${{ inputs.RELEASE_TYPE }}-GH_Run#:${{ github.run_number }}-Date:$current_date" | ||
echo "Setting version to: $version" | ||
echo "version=$version" >> $GITHUB_ENV | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Sinbad Production Workflow | ||
on: | ||
push: | ||
tags: | ||
- production_* | ||
jobs: | ||
build_test_and_publish: | ||
name: Build, Test and Publish to Cloudflare Pages Production | ||
runs-on: ubuntu-latest | ||
outputs: | ||
RELEASE_VERSION: ${{ steps.extract_version.outputs.RELEASE_VERSION }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install npm packages | ||
uses: "./.github/actions/npm_install_from_cache" | ||
- name: Build | ||
uses: "./.github/actions/build" | ||
with: | ||
NODE_ENV: production | ||
- name: Versioning | ||
uses: "./.github/actions/tag" | ||
with: | ||
release_type: production | ||
- name: Extract version | ||
id: extract_version | ||
run: echo "RELEASE_VERSION=${version}" >> $GITHUB_OUTPUT | ||
- name: Publish to Cloudflare Pages Production | ||
uses: "./.github/actions/publish_to_pages_production" | ||
with: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
|
||
send_slack_notification: | ||
name: Send Slack notification | ||
runs-on: ubuntu-latest | ||
if: always() | ||
needs: [build_test_and_publish] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Send Slack Notification | ||
uses: "./.github/actions/send_slack_notifications" | ||
with: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} | ||
status: ${{ env.WORKFLOW_CONCLUSION }} | ||
release_type: Production | ||
version: ${{ needs.build_test_and_publish.outputs.RELEASE_VERSION}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Sinbad Staging Workflow | ||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_test_and_publish: | ||
name: Build, Test and Publish to Cloudflare Staging | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Tag | ||
uses: "./.github/actions/tag" | ||
- name: Install npm packages | ||
uses: "./.github/actions/npm_install_from_cache" | ||
- name: Build | ||
uses: "./.github/actions/build" | ||
with: | ||
NODE_ENV: staging | ||
- name: Publish to Cloudflare Pages Staging | ||
uses: "./.github/actions/publish_to_pages_staging" | ||
with: | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Sinbad Test Workflow | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
build_and_test: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install npm packages | ||
uses: "./.github/actions/npm_install_from_cache" | ||
- name: Build | ||
uses: "./.github/actions/build" |