Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Shayan/FEQ-911/github-actions-implementation #377

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: build
inputs:
GD_API_KEY:
description: 'Google drive api key'
required: false
GD_APP_ID:
description: 'Google drive app id'
required: false
GD_CLIENT_ID:
description: 'Google drive client id'
required: false
TRACKJS_TOKEN:
description: 'trackjs token'
required: false
runs:
steps:
- name: Build all packages
env:
GD_CLIENT_ID: ${{ inputs.GD_CLIENT_ID }}
GD_API_KEY: ${{ inputs.GD_API_KEY }}
GD_APP_ID: ${{ inputs.GD_APP_ID }}
TRACKJS_TOKEN: ${{ inputs.TRACKJS_TOKEN }}
run: npm run build
shell: bash
33 changes: 33 additions & 0 deletions .github/actions/git_checkout_from_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: git_checkout_from_cache
runs:
using: composite
steps:
- name: restore_cache
uses: actions/[email protected]
with:
key: source-v1-{{ .Branch }}-{{ .Revision }}
path: node_modules
restore-keys: |-
source-v1-{{ .Branch }}-{{ .Revision }}
source-v1-{{ .Branch }}-
source-v1-
- name: Fetch git tags
run: |-
mkdir -p ~/.ssh
ssh-keygen -F github.com || ssh-keyscan github.com >> ~/.ssh/known_hosts
echo 'github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== ' >> ~/.ssh/known_hosts
# Fetch tags if git cache is present
if [ -e /home/circleci/project/.git ]
then
git fetch origin --tags -f
fi
shell: bash
- uses: actions/[email protected]
- name: Compress git objects
run: git gc
shell: bash
- name: save_cache
uses: actions/[email protected]
with:
path: ".git"
key: source-v1-{{ .Branch }}-{{ .Revision }}
20 changes: 20 additions & 0 deletions .github/actions/npm_install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: npm_install
runs:
using: composite
steps:
- name: restore_cache
uses: actions/[email protected]
with:
key: npm-v1-{{ checksum "package.json" }}
path: node_modules
restore-keys: |-
npm-v1-{{ checksum "package.json" }}
npm-v1-
- name: Install npm modules
run: npm install
shell: bash
- name: save_cache
uses: actions/[email protected]
with:
path: node_modules
key: npm-v1-{{ checksum "package.json" }}
10 changes: 10 additions & 0 deletions .github/actions/publish_to_pages_production/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: publish_to_pages_production
runs:
using: composite
steps:
- name: Publish to cloudflare pages (production)
run: |-
cd www
npx wrangler pages publish . --project-name=deriv-binary-bot-pages --branch=main
echo "New website - http://cf-pages-deriv-binary-bot.deriv.com"
shell: bash
10 changes: 10 additions & 0 deletions .github/actions/publish_to_pages_staging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: publish_to_pages_staging
runs:
using: composite
steps:
- name: Publish to cloudflare pages (staging)
run: |-
cd www
npx wrangler pages publish . --project-name=deriv-binary-bot-pages --branch=staging
echo "New staging website - http://staging.cf-pages-deriv-binary-bot.deriv.com"
shell: bash
39 changes: 39 additions & 0 deletions .github/actions/send_slack_notifications/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: send_slack_notifications
description: Send Slack notifications
inputs:
SLACK_WEBHOOK_URL:
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 deriv bot 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 deriv bot with version ${{ inputs.VERSION }}"
}' \
${{ inputs.SLACK_WEBHOOK_URL }}
shell: bash
10 changes: 10 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: run_tests
runs:
using: composite
steps:
- name: run tests
run: |
for i in {1..3}; do
npm test && break
done
shayan-deriv marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: deriv-com/binary-bot/release
on:
push:
branches:
- master
jobs:
release_staging:
if: # GitHub does not currently support regular expressions inside if conditions
# github.ref == 'refs/heads//^master$/'
runs-on: ubuntu-latest
container:
image: node:18.16
steps:
- uses: actions/[email protected]
- uses: "./.github/actions/git_checkout_from_cache"
- uses: "./.github/actions/npm_install"
# # This item has no matching transformer
# - test:
- uses: "./.github/actions/build"
- uses: actions/[email protected]
with:
path: www/.
# # `run` was not transformed because it is missing a `command`
- uses: "./.github/actions/notify_slack"
publish_cloudflare_staging:
if: # GitHub does not currently support regular expressions inside if conditions
# github.ref == 'refs/heads//^master$/'
runs-on: ubuntu-latest
container:
image: node:20.2.0
needs:
- release_staging
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: www
- uses: "./.github/actions/publish_to_pages_staging"
release_production:
if: # GitHub does not currently support regular expressions inside if conditions
# (github.ref == 'refs/tags//^production.*/') && (github.ref != 'refs/heads//.*/')
runs-on: ubuntu-latest
container:
image: node:18.6
steps:
- uses: actions/[email protected]
- uses: "./.github/actions/git_checkout_from_cache"
- uses: "./.github/actions/npm_install"
# # This item has no matching transformer
# - test:
- uses: "./.github/actions/build"
- uses: actions/[email protected]
with:
path: www/.
# # `run` was not transformed because it is missing a `command`
- uses: "./.github/actions/notify_slack"
publish_cloudflare_production:
if: # GitHub does not currently support regular expressions inside if conditions
# (github.ref == 'refs/tags//^production.*/') && (github.ref != 'refs/heads//.*/')
runs-on: ubuntu-latest
container:
image: node:20.2.0
needs:
- release_production
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: www
- uses: "./.github/actions/publish_to_pages_production"
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: deriv-com/binary-bot/test
on:
push:
branches:
- '*'
- '!master'
jobs:
test:
runs-on: ubuntu-latest
container:
image: node:18.16
steps:
# - uses: actions/[email protected]
shayan-deriv marked this conversation as resolved.
Show resolved Hide resolved
- uses: "./.github/actions/git_checkout_from_cache"
- uses: "./.github/actions/npm_install"
- uses: "./.github/actions/test"