Skip to content

Commit

Permalink
Added action to deploy to staging
Browse files Browse the repository at this point in the history
  • Loading branch information
PavlosIsaris committed Oct 7, 2024
1 parent 3a3e57d commit da15469
Show file tree
Hide file tree
Showing 2 changed files with 138 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-secondary-staging.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to Secondary Staging Server
name: Deploy to Secondary Staging Server (ECAS Installation)

on:
workflow_dispatch:
Expand Down
137 changes: 137 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Deploy to Staging Server (SciFY Installation - "Together")

on:
workflow_dispatch:
push:
branches:
- staging_scify_org

env:
PHP_VERSION: '8.2'
SERVER_HOSTNAME: 'staging.scify.org'
REMOTE_USER: 'project_crowdsourcing'
PROJECT_URL: 'crowdsourcing.scify.org'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/[email protected]

- name: Install wireguard
run: sudo apt install wireguard

- name: Create wg0 file
uses: cuchi/[email protected]
with:
template: .github/templates/wg0.j2
output_file: wg0.conf
variables: |
WIREGUARD_PRIVATE_KEY=${{ secrets.WIREGUARD_PRIVATE_KEY }}
VPN_SERVER_PUBLIC_KEY=${{ secrets.VPN_SERVER_PUBLIC_KEY }}


- name: Move wg0.conf to /etc/wireguard
run: sudo mv wg0.conf /etc/wireguard/wg0.conf

- name: Start wireguard
run: sudo wg-quick up wg0

- name: Checkout repo
uses: actions/[email protected]

- name: Add frodo to etc hosts
run: echo "10.10.0.100 frodo.scify.org" | sudo tee -a /etc/hosts

- name: read password from vault
uses: hashicorp/vault-action@v2
with:
url: https://frodo.scify.org:8200
caCertificate: ${{ secrets.VAULT_CA_CERT }}
method: userpass
username: ${{ secrets.VAULT_USER }}
password: ${{ secrets.VAULT_PASSWORD }}
secrets: |
Projects/data/crowdsourcing/scify-installation-together/staging/database db_name | DB_NAME ;
Projects/data/crowdsourcing/scify-installation-together/staging/database db_user | DB_USER ;
Projects/data/crowdsourcing/scify-installation-together/staging/database password | DB_PASSWORD ;
Projects/data/crowdsourcing/staging_sec_data/google_client_secrets google_client_id | GOOGLE_CLIENT_ID ;
Projects/data/crowdsourcing/production/email/laravel_mailgun_env_variables MAILGUN_SECRET | MAILGUN_SECRET ;



- name: Create .env file
uses: cuchi/[email protected]
with:
template: .github/templates/.env.j2
output_file: .env
variables: |
DB_NAME=${{ env.DB_NAME }}
DB_USER=${{ env.DB_USER }}
DB_PASSWORD=${{ env.DB_PASSWORD }}
LARAVEL_STAGING_SCIFY_APP_KEY=${{ secrets.LARAVEL_STAGING_SCIFY_APP_KEY }}
PROJECT_URL=${{ env.PROJECT_URL }}
MAILGUN_SECRET=${{ env.MAILGUN_SECRET }}
PERSONAL_CLIENT_ID=${{ secrets.PERSONAL_CLIENT_ID }}
PERSONAL_CLIENT_SECRET=${{ secrets.PERSONAL_CLIENT_SECRET }}
PASSWORD_CLIENT_SECRET=${{ secrets.PASSWORD_CLIENT_SECRET }}
FACEBOOK_CLIENT_ID=${{ secrets.FACEBOOK_CLIENT_ID }}
FACEBOOK_CLIENT_SECRET=${{ secrets.FACEBOOK_CLIENT_SECRET }}
TWITTER_CLIENT_ID=${{ secrets.TWITTER_CLIENT_ID }}
TWITTER_CLIENT_SECRET=${{ secrets.TWITTER_CLIENT_SECRET }}
GOOGLE_CLIENT_ID=${{ env.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}
MICROSOFT_CLIENT_ID=${{ secrets.MICROSOFT_CLIENT_ID }}
MICROSOFT_CLIENT_SECRET=${{ secrets.MICROSOFT_CLIENT_SECRET }}
LINKEDIN_CLIENT_ID=${{ secrets.LINKEDIN_CLIENT_ID }}
LINKEDIN_CLIENT_SECRET=${{ secrets.LINKEDIN_CLIENT_SECRET }}
DEFAULT_ADMIN_USER_PASSWORD_FOR_SEED=${{ secrets.DEFAULT_ADMIN_USER_PASSWORD_FOR_SEED }}
GOOGLE_TRANSLATE_KEY=${{ secrets.GOOGLE_TRANSLATE_KEY }}
MAILCHIMP_API_KEY=${{ secrets.MAILCHIMP_API_KEY }}
SENTRY_LARAVEL_DSN=${{ secrets.SENTRY_LARAVEL_DSN }}
API_AUTH_TOKEN=${{ secrets.API_AUTH_TOKEN }}
USERWAY_ID=${{ secrets.USERWAY_ID }}
AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}

- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'

- name: Install node dependencies
run: npm install

- name: Build assets
run: npm run build


- name: SCP files to staging server
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY_STAGING_SERVER }}
REMOTE_PORT: 222
SOURCE: "./"
REMOTE_HOST: ${{ env.SERVER_HOSTNAME }}
REMOTE_USER: ${{ env.REMOTE_USER }}
TARGET: "/home/${{ env.REMOTE_USER }}/www/${{ env.PROJECT_URL }}"


- name: Run composer install on remote server
uses: appleboy/[email protected]
with:
host: ${{ env.SERVER_HOSTNAME }}
port: 222
username: ${{ env.REMOTE_USER }}
key: ${{ secrets.SSH_KEY_STAGING_SERVER }}
script: |
source /home/${{ env.REMOTE_USER }}/.profile
cd /home/${{ env.REMOTE_USER }}/www/${{ env.PROJECT_URL }}
composer install --no-interaction --no-progress --optimize-autoloader
# --no-dev

0 comments on commit da15469

Please sign in to comment.