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

Create Staging Environment on Render #34

Create Staging Environment on Render

Create Staging Environment on Render #34

Workflow file for this run

name: Create Staging Environment on Render
on:
workflow_dispatch:
inputs:
PR_number:
description: 'Pull request number'
required: true
jobs:
Create:
name: 'Create Staging and Deploy'
runs-on: ubuntu-latest
env:
RENDER_CLIENT_SERVICE_ID: ${{ secrets.RENDER_CLIENT_SERVICE_ID }}
RENDER_SERVER_SERVICE_ID: ${{ secrets.RENDER_SERVER_SERVICE_ID }}
RENDER_API_TOKEN: ${{ secrets.RENDER_API_TOKEN }}
steps:
- name: Verify The Pull Request Number
uses: actions/github-script@v5
id: verify_pr_number
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ github.event.inputs.PR_number }}
});
if (response.data.state !== 'open') {
throw new Error('Pull request is not open or number is not valid!');
}
return response.data.head.ref;
- name: Debug Branch Name
run: |
echo "Branch Name: ${{ steps.verify_pr_number.outputs.result }}"
- name: Clean Branch Name
id: clean_branch_name
run: |
echo "BRANCH_NAME=${{ steps.verify_pr_number.outputs.result }}" >> $GITHUB_ENV
- name: Checkout PR Branch
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install Dependencies
run: |
cd ./client
npm install
cd ../server
npm install
- name: Build Frontend
run: |
cd ./client
npm run build
# - name: Print global.css File Contents
# run: cat ./client/dist/assets/global.css
# - name: Verify CSS Change
# run: |
# grep 'background-color: yellow;' ./client/dist/assets/global.css || echo "Background color change not found in build output"
# - name: Print File Tree
# run: ls -R ./client/dist
# - name: Check Build Output
# run: cat ./client/dist/index.html
- name: Deploy Frontend to Render
uses: johnbeynon/[email protected]
with:
service-id: ${{ env.RENDER_CLIENT_SERVICE_ID }}
api-key: ${{ env.RENDER_API_TOKEN }}
- name: Deploy Backend to Render
uses: johnbeynon/[email protected]
with:
service-id: ${{ env.RENDER_SERVER_SERVICE_ID }}
api-key: ${{ env.RENDER_API_TOKEN }}
- name: 'Setup tmate session'
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}