updated to v 9.12 #85
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: Deploy Application | |
on: | |
push: | |
branches: [main, revert] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
create-deployment-environment: | |
name: Create Deployment Environment | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 21 | |
cache: 'npm' | |
- name: Compile Assets | |
run: | | |
npm install | |
npm run prod | |
- name: Configure PHP | |
uses: shivammathur/setup-php@master | |
with: | |
php-version: 8.2 | |
- name: Configure Composer | |
run: | | |
composer update | |
composer install --optimize-autoloader --no-dev --no-interaction --prefer-dist | |
- name: Create Deployment archive | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
run: tar -czf "${GITHUB_SHA}".tar.gz --exclude=*.git --exclude=node_modules * | |
- name: Store archive for distribution | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-build | |
path: ${{github.sha}}.tar.gz | |
prepare-release-on-server: | |
name: Prepare release on server | |
runs-on: ubuntu-latest | |
needs: create-deployment-environment | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: app-build | |
- name: Upload | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ SECRETS.SERVER_HOST }} | |
port: ${{ SECRETS.SERVER_PORT }} | |
username: ${{ SECRETS.SERVER_USERNAME }} | |
password: ${{ SECRETS.SERVER_PASSWORD }} | |
source: ${{github.sha}}.tar.gz | |
target: domains/codebumble.net/public_html | |
- name: Extract archive and create directory | |
uses: appleboy/ssh-action@master | |
env: | |
GITHUB_SHA: ${{ github.sha }} | |
with: | |
host: ${{ SECRETS.SERVER_HOST }} | |
port: ${{ SECRETS.SERVER_PORT }} | |
username: ${{ SECRETS.SERVER_USERNAME }} | |
password: ${{ SECRETS.SERVER_PASSWORD }} | |
envs: GITHUB_SHA | |
script: | | |
rm -rf domains/codebumble.net/public_html/cbl_system | |
mkdir -p domains/codebumble.net/public_html/cbl_system | |
tar xzf domains/codebumble.net/public_html/${GITHUB_SHA}.tar.gz -C "domains/codebumble.net/public_html/cbl_system" | |
active-release: | |
name: Codebumble Server 1 - Active Release | |
runs-on: ubuntu-latest | |
needs: [create-deployment-environment, prepare-release-on-server] | |
steps: | |
- name: Active Release | |
uses: appleboy/ssh-action@master | |
env: | |
GITHUB_SHA: ${{github.sha}} | |
BASE_PATH: domains/codebumble.net/public_html/cbl_system | |
PROJECT_ENV: ${{ SECRETS.PROJECT_ENV }} | |
CONF_CACHE: ${{ SECRETS.CONF_CACHE }} | |
ROUTE_CACHE: ${{ SECRETS.ROUTE_CACHE }} | |
VIEW_CACHE: ${{ SECRETS.VIEW_CACHE }} | |
HTACCESS: ${{ SECRETS.HTACCESS }} | |
with: | |
host: ${{ SECRETS.SERVER_HOST }} | |
port: ${{ SECRETS.SERVER_PORT }} | |
username: ${{ SECRETS.SERVER_USERNAME }} | |
password: ${{ SECRETS.SERVER_PASSWORD }} | |
envs: GITHUB_SHA,BASE_PATH,PROJECT_ENV,CONF_CACHE,ROUTE_CACHE,VIEW_CACHE,HTACCESS | |
script: | | |
echo ${GITHUB_SHA} | |
printf "%s" "$PROJECT_ENV" > "${BASE_PATH}/.env" | |
printf "%s" "${GITHUB_SHA}" > "${BASE_PATH}/${GITHUB_SHA}.txt" | |
printf "%s" "$HTACCESS" > "${BASE_PATH}/.htaccess" | |
cd ${BASE_PATH} && ${CONF_CACHE} && ${ROUTE_CACHE} && ${VIEW_CACHE} | |
migrating-db: | |
name: Migrating Database | |
runs-on: ubuntu-latest | |
needs: | |
[create-deployment-environment, prepare-release-on-server, active-release] | |
steps: | |
- name: Migration Init | |
uses: appleboy/ssh-action@master | |
env: | |
BASE_PATH: domains/codebumble.net/public_html/cbl_system | |
ARTISAN_MIGRATE: ${{ SECRETS.ARTISAN_MIGRATE }} | |
with: | |
envs: BASE_PATH,ARTISAN_MIGRATE, | |
host: ${{ SECRETS.SERVER_HOST }} | |
port: ${{ SECRETS.SERVER_PORT }} | |
username: ${{ SECRETS.SERVER_USERNAME }} | |
password: ${{ SECRETS.SERVER_PASSWORD }} | |
script: | | |
cd ${BASE_PATH} && ${ARTISAN_MIGRATE} | |
github-cleanup: | |
name: Github Cleanup | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
create-deployment-environment, | |
prepare-release-on-server, | |
active-release, | |
migrating-db, | |
] | |
steps: | |
- name: Cleaning Artifacts Github | |
uses: geekyeggo/delete-artifact@v2 | |
with: | |
name: app-build | |
failOnError: false | |
clean-up: | |
name: Cleaning Up Artifacts | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
create-deployment-environment, | |
prepare-release-on-server, | |
active-release, | |
migrating-db, | |
] | |
steps: | |
- name: Clean up server junk | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ SECRETS.SERVER_HOST }} | |
port: ${{ SECRETS.SERVER_PORT }} | |
username: ${{ SECRETS.SERVER_USERNAME }} | |
password: ${{ SECRETS.SERVER_PASSWORD }} | |
script: | | |
rm -rf domains/codebumble.net/public_html/${{github.sha}}.tar.gz | |
rm -rf domains/codebumble.net/public_html/cbl_system/${{github.sha}}.txt | |