Last active
June 3, 2023 07:30
-
-
Save alic-xc/1963e8f9a30973d7d13886afd9f9e700 to your computer and use it in GitHub Desktop.
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: UI Deployment | |
# In this section, two enivorment variables are created which will be use in the section of the configuration | |
env: | |
DEPLOY_PACKAGE_NAME_FILE: "${{ github.sha }}.zip" | |
DEPLOY_PACKAGE_NAME: "${{ github.sha }}" | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the production branch | |
push: | |
branches: [production] | |
# 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" | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git clone https://github.com/yorgit.git | |
uses: actions/checkout@v2 | |
- name: This create an env file incase we need one. | |
run: | | |
touch .env | |
echo VITE_APP_BASE_URL=${{ secrets.APP_BASE_URL }} >> .env | |
- name: Install And Build Our React App | |
run: npm install && npm run build | |
- name: Create zip deployment package | |
run: zip -r ${{ env.DEPLOY_PACKAGE_NAME_FILE }} ./dist/ -x *.git* | |
- name: copy file via ssh password | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.LIGTHSAIL_IP }} | |
username: ${{ secrets.LIGTHSAIL_USERNAME }} | |
key: ${{ secrets.LIGTHSAIL_KEY }} | |
password: "" | |
passphrase: "" | |
port: 22 | |
source: ${{ env.DEPLOY_PACKAGE_NAME_FILE }} | |
target: "/home/${{ secrets.LIGTHSAIL_USERNAME }}" | |
- name: Connect to AWS Lightsail, extract file and delete the file | |
uses: appleboy/ssh-action@v0.1.7 | |
with: | |
host: ${{ secrets.LIGTHSAIL_IP }} | |
username: ${{ secrets.LIGTHSAIL_USERNAME }} | |
key: ${{ secrets.LIGTHSAIL_KEY }} | |
password: "" | |
passphrase: "" | |
port: 22 | |
script: | | |
sudo apt-get install zip unzip | |
unzip -q -o /home/${{ secrets.LIGTHSAIL_USERNAME }}/${{ env.DEPLOY_PACKAGE_NAME_FILE }} -d /home/${{ secrets.LIGTHSAIL_USERNAME }}/${{ secrets.LIGTHSAIL_ROOT_DIR }} | |
rm /home/${{ secrets.LIGTHSAIL_USERNAME }}/${{ env.DEPLOY_PACKAGE_NAME_FILE }} | |
sudo systemctl restart nginx | |
- name: Deployment completed Successfully | |
run: echo "Deployment completed successfuly" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment