Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Sean/cache public and cache directories during GH actions build #1971

Merged
4 commits merged into from Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
198 changes: 102 additions & 96 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,117 @@
name: Release Production

on:
push:
tags:
- 'production*'
paths-ignore:
- '**.md'
push:
tags:
- 'production*'
paths-ignore:
- '**.md'

env:
GATSBY_CPU_COUNT: 2
GATSBY_ENV: production
GATSBY_CPU_COUNT: 2
GATSBY_ENV: production

jobs:
lint:
timeout-minutes: 10
runs-on: ubuntu-latest
lint:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/[email protected]
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/[email protected]

- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache dependencies
id: cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install Node.js dependencies
run: |
npm ci
npm test
- name: Run linters
uses: wearerequired/lint-action@v1
with:
eslint: true
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache dependencies
id: cache
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ./node_modules
key: modules-${{ hashFiles('package-lock.json') }}
- name: Install Node.js dependencies
run: |
npm ci
npm test

release-production:
needs: lint
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/[email protected]

- name: Setup Node
uses: actions/[email protected]
with:
node-version: '12.x'
release-production:
needs: lint
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›ŽοΈ
uses: actions/[email protected]

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- run: npm ci
- run: npm run format
- run: npm run test
- run: npm run build
- uses: olegtarasov/[email protected]
id: tagName
# For using same tag for staging and production we need to uncomment these two below lines:
# with:
# tagRegex: "production(.*)"
- name: Building docker image 🐳
run: docker build -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME .
- name: Setup Node
uses: actions/[email protected]
with:
node-version: '12.x'

- name: Pushing Image to docker hub 🐳
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Deploy πŸš€
run: |
export NAMESPACE="deriv-com-production"
export SERVICEACCOUNT_TOKEN=${{ secrets.SERVICEACCOUNT_TOKEN }}
export DOCKERHUB_ORGANISATION=${{ secrets.DOCKERHUB_ORGANISATION }}
export KUBE_SERVER=${{ secrets.KUBE_SERVER }}
export CA=${{ secrets.CA }}
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo ${{ secrets.CA_CRT}} | base64 --decode > ca.crt
./release.sh deriv-com $GIT_TAG_NAME
- name: Cache Gatsby
id: gatsby-cache-build
uses: actions/cache@v2
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-gatsby-build-

- name: Slack Notification πŸ“£
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()
- run: npm ci
- run: npm run format
- run: npm run test
- run: npm run build
- uses: olegtarasov/[email protected]
id: tagName
# For using same tag for staging and production we need to uncomment these two below lines:
# with:
# tagRegex: "production(.*)"
- name: Building docker image 🐳
run: docker build -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest -t ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME .

- name: Pushing Image to docker hub 🐳
run: |
echo ${{ secrets.DOCKERHUB_PASSWORD }}| docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:latest
docker push ${{ secrets.DOCKHUB_ORGANISATION }}/deriv-com:$GIT_TAG_NAME

- name: Deploy πŸš€
run: |
export NAMESPACE="deriv-com-production"
export SERVICEACCOUNT_TOKEN=${{ secrets.SERVICEACCOUNT_TOKEN }}
export DOCKERHUB_ORGANISATION=${{ secrets.DOCKERHUB_ORGANISATION }}
export KUBE_SERVER=${{ secrets.KUBE_SERVER }}
export CA=${{ secrets.CA }}
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo ${{ secrets.CA_CRT}} | base64 --decode > ca.crt
./release.sh deriv-com $GIT_TAG_NAME

- name: Slack Notification πŸ“£
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: workflow,repo
if_mention: failure,cancelled
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Release for *Deriv.com* with version *$GIT_TAG_NAME*`
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
if: always()
Loading