Created
June 30, 2023 15:13
-
-
Save mannyanebi/09f59b52e5f1adf8c799779ed823454b to your computer and use it in GitHub Desktop.
Dev CI Pipeline Yaml
This file contains hidden or 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: Dev Headless-Typescript | |
on: | |
push: | |
branches: [dev] | |
pull_request: | |
branches: [dev] | |
jobs: | |
build-test-job: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
node-version: [14.17.5] | |
# node-version: [14.x, 16.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- name: Install Dependencies | |
run: yarn --prefer-offline | |
- name: Make build .env file | |
uses: SpicyPizza/[email protected] | |
with: | |
envkey_NEXT_PUBLIC_BASE_URL: ${{ secrets.DEV_NEXT_PUBLIC_BASE_URL }} | |
envkey_NEXT_PUBLIC_PHOTO_URL: ${{ secrets.DEV_NEXT_PUBLIC_PHOTO_URL }} | |
envkey_NEXT_PUBLIC_ENVIRONMENT_PROTOCOL: ${{ secrets.DEV_NEXT_PUBLIC_ENVIRONMENT_PROTOCOL }} | |
envkey_NEXT_PUBLIC_DEV_HOSTNAME: ${{ secrets.DEV_NEXT_PUBLIC_DEV_HOSTNAME }} | |
envkey_NEXT_PUBLIC_USER_IMAGE_PLACEHOLDER: ${{ secrets.DEV_NEXT_PUBLIC_USER_IMAGE_PLACEHOLDER }} | |
envkey_NEXT_PUBLIC_PUSHER_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PUSHER_KEY }} | |
envkey_NEXT_PUBLIC_PAYMENT_API_MODE: ${{ secrets.DEV_NEXT_PUBLIC_PAYMENT_API_MODE }} | |
envkey_NEXT_PUBLIC_PAYSTACK_TEST_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PAYSTACK_TEST_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_PAYSTACK_LIVE_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PAYSTACK_LIVE_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_FLUTTERWAVE_TEST_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_FLUTTERWAVE_TEST_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_FLUTTERWAVE_LIVE_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_FLUTTERWAVE_LIVE_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_CLARITY_ID: ${{ secrets.DEV_NEXT_PUBLIC_CLARITY_ID }} | |
file_name: .env.production | |
fail_on_empty: true | |
- name: Build | |
run: yarn build | |
deploy-job: | |
runs-on: ubuntu-latest | |
needs: [build-test-job] # will be fired if and only if build-test-job is passed. | |
if: ${{ github.event_name == 'push' }} # will be fired if the trigger event is a push event. | |
strategy: | |
max-parallel: 4 | |
matrix: | |
node-version: [14.17.5] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- name: Install Dependencies | |
run: yarn --prefer-offline | |
- name: Make build .env file | |
uses: SpicyPizza/[email protected] | |
with: | |
envkey_NEXT_PUBLIC_BASE_URL: ${{ secrets.DEV_NEXT_PUBLIC_BASE_URL }} | |
envkey_NEXT_PUBLIC_PHOTO_URL: ${{ secrets.DEV_NEXT_PUBLIC_PHOTO_URL }} | |
envkey_NEXT_PUBLIC_ENVIRONMENT_PROTOCOL: ${{ secrets.DEV_NEXT_PUBLIC_ENVIRONMENT_PROTOCOL }} | |
envkey_NEXT_PUBLIC_DEV_HOSTNAME: ${{ secrets.DEV_NEXT_PUBLIC_DEV_HOSTNAME }} | |
envkey_NEXT_PUBLIC_USER_IMAGE_PLACEHOLDER: ${{ secrets.DEV_NEXT_PUBLIC_USER_IMAGE_PLACEHOLDER }} | |
envkey_NEXT_PUBLIC_PUSHER_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PUSHER_KEY }} | |
envkey_NEXT_PUBLIC_PAYMENT_API_MODE: ${{ secrets.DEV_NEXT_PUBLIC_PAYMENT_API_MODE }} | |
envkey_NEXT_PUBLIC_PAYSTACK_TEST_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PAYSTACK_TEST_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_PAYSTACK_LIVE_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_PAYSTACK_LIVE_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_FLUTTERWAVE_TEST_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_FLUTTERWAVE_TEST_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_FLUTTERWAVE_LIVE_PUBLIC_KEY: ${{ secrets.DEV_NEXT_PUBLIC_FLUTTERWAVE_LIVE_PUBLIC_KEY }} | |
envkey_NEXT_PUBLIC_CLARITY_ID: ${{ secrets.DEV_NEXT_PUBLIC_CLARITY_ID }} | |
file_name: .env.production | |
fail_on_empty: true | |
- name: Build | |
run: yarn build | |
- name: Copy repository contents via scp to remote server | |
uses: appleboy/[email protected] | |
env: | |
HOST: ${{ secrets.DEVHTS_HOSTNAME }} | |
USERNAME: ${{ secrets.DEVHTS_USERNAME }} | |
PORT: 22 | |
KEY: ${{ secrets.DEVHTS_SSHKEY }} | |
with: | |
source: "." | |
target: "~/headless-typescript" | |
- name: Executing remote command | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.DEVHTS_HOSTNAME }} | |
username: ${{ secrets.DEVHTS_USERNAME }} | |
port: 22 | |
key: ${{ secrets.DEVHTS_SSHKEY }} | |
command_timeout: 20m | |
script: | | |
pm2 restart headless-typescript | |
slack-notify: | |
runs-on: ubuntu-latest | |
needs: [ deploy-job ] | |
if: ${{ always() }} | |
steps: | |
- name: Slack Notification | |
uses: rtCamp/action-slack-notify@v2 | |
env: | |
SLACK_WEBHOOK: ${{ secrets.DEV_SLACK_BUILD_WEBHOOK }} | |
SLACK_CHANNEL: cicd-headless | |
SLACK_COLOR: ${{ needs.deploy-job.result }} # or a specific color like 'green' or '#ff00ff' | |
SLACK_ICON: https://avatars.githubusercontent.com/u/83184026?s=200&v=4 | |
SLACK_USERNAME: Deployment Bot | |
SLACK_MESSAGE: '${{ github.repository }} Deployment ${{ github.run_number }} to ${{ github.workflow }} ended in a ${{ needs.deploy-job.result }} :rocket:' | |
SLACK_TITLE: Message | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment