Skip to content

Commit

Permalink
Merge pull request #248 from hostinger/feat/cd_cd
Browse files Browse the repository at this point in the history
feat: Add CI/CD
  • Loading branch information
teodorascele authored Sep 12, 2024
2 parents 8e6444a + da83d32 commit 4519d4c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy code on remote host
on:
workflow_call:
inputs:
host:
description: 'Host to deploy changes on'
required: true
type: string
path:
description: 'Path to webserver directory'
required: true
type: string

jobs:
run-php-tests:
runs-on: fireactions-bnk-c2-m4

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
- name: Deploy changes on ${{ inputs.host }} server
run: |
ssh -o StrictHostKeyChecking=no apache@${{ inputs.host }} << EOF
set -e
mkdir -p ${{ inputs.path }}
cd ${{ inputs.path }}
if [ ! -d "${{ inputs.path }}" ]; then
git clone [email protected]:${{ github.repository }}.git
fi
git fetch origin
git checkout ${{ github.sha }}
chown apache:apache -R ${{ inputs.path }}
EOF
17 changes: 17 additions & 0 deletions .github/workflows/deploy_canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy master branch on remote host

on:
workflow_dispatch:
push:
branches:
- master

concurrency:
group: deploy-master

jobs:
deploy-master:
uses: ./.github/workflows/deploy.yml
with:
host: fr-int-wpupdate.hostinger.io
path: /var/www/html/master
17 changes: 17 additions & 0 deletions .github/workflows/deploy_master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy master branch on remote host

on:
workflow_dispatch:
push:
branches:
- master

concurrency:
group: deploy-master

jobs:
deploy-master:
uses: ./.github/workflows/deploy.yml
with:
host: fr-int-wpupdate.hostinger.io
path: /var/www/html/master
17 changes: 17 additions & 0 deletions .github/workflows/deploy_staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Deploy staging branch on remote host

on:
workflow_dispatch:
push:
branches:
- staging

concurrency:
group: deploy-staging

jobs:
deploy-staging:
uses: ./.github/workflows/deploy.yml
with:
host: fr-int-wpupdate.hostinger.io
path: /var/www/html/staging

0 comments on commit 4519d4c

Please sign in to comment.