chore: removes CI build step (#45) #50
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
name: CD | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push events but only for the main branch | |
push: | |
branches: [main] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
# This workflow contains a single job called "build" | |
deploy: | |
name: Build and Deploy Application to Server | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- name: Check out Git repository | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
with: | |
version: latest | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
# Install project packages and build project | |
- name: Install PNPM Packages | |
run: pnpm i | |
# Install dependencies using composer.json in public/api | |
- name: Install PHP Packages | |
uses: "ramsey/composer-install@v3" | |
with: | |
working-directory: "public/api" | |
# Add Firebase API keys to environment variables | |
- name: Add environment variables | |
uses: SpicyPizza/create-envfile@v2 | |
with: | |
envkey_NEXT_PUBLIC_FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }} | |
envkey_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN: ${{ secrets.FIREBASE_AUTH_DOMAIN }} | |
envkey_NEXT_PUBLIC_FIREBASE_DATABASE_URL: ${{ secrets.FIREBASE_DATABASE_URL }} | |
envkey_NEXT_PUBLIC_FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} | |
envkey_NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET: ${{ secrets.FIREBASE_STORAGE_BUCKET }} | |
envkey_NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.FIREBASE_MESSAGING_SENDER_ID }} | |
envkey_NEXT_PUBLIC_FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} | |
envkey_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: ${{ secrets.FIREBASE_MEASUREMENT_ID }} | |
envkey_NEXT_PUBLIC_GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }} | |
- name: Build project | |
run: pnpm build | |
- name: Package build | |
run: | | |
tar -czvf deploy.tar.gz -C out . | |
ls | |
- name: Send packaged build to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
source: "deploy.tar.gz" | |
target: ${{ secrets.SERVER_ABSOLUTE_PATH }} | |
- name: Replace previous version and deploy new one | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
password: ${{ secrets.SSH_PASSWORD }} | |
port: ${{ secrets.SSH_PORT }} | |
script_stop: true | |
script: | | |
echo "Changing directory to server location" | |
cd ${{ secrets.SERVER_ABSOLUTE_PATH }} | |
echo "Moving old version to a temporary folder" | |
mkdir ../old_version | |
shopt -s dotglob | |
mv * ../old_version/ | |
echo "Unzip new version to server location" | |
tar -xf ../old_version/deploy.tar.gz -C . | |
echo "Move .htaccess to root directory" | |
mv ./assets/.htaccess . | |
echo "Move exceptions back to server" | |
mv ../old_version/AssinaturaMail-NAO-APAGAR . | |
mv ../old_version/boatdata . | |
mv ../old_version/facebookTab . | |
mv ../old_version/horarios . | |
mv ../old_version/OpenSource . | |
mv ../old_version/protected . | |
mv ../old_version/terms_and_conditions.html . | |
mv ../old_version/privacy_policy.html . | |
mv ../old_version/public . | |
echo "Removing old version" | |
rm -rf ../old_version | |
shopt -u dotglob | |
echo "Deployment Complete" |