Skip to content

Commit

Permalink
deploy change
Browse files Browse the repository at this point in the history
  • Loading branch information
hmbanan666 committed Jun 9, 2024
1 parent c83741c commit 184763e
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/app-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,56 @@ name: App – Deploy Docker Image on server
on:
workflow_dispatch:

env:
APP_URL: https://chatgame.space

jobs:
deploy:
name: Deploy image
runs-on: ubuntu-latest
permissions:
deployments: write

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

- uses: chrnorm/deployment-action@v2
name: Create GitHub deployment
id: deployment
with:
token: '${{ github.token }}'
environment-url: ${{ env.APP_URL }}
environment: production

- name: Install ssh keys
# check this thread to understand why its needed:
# <https://stackoverflow.com/a/70447517>
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts
- name: Connect and pull
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && docker compose pull && docker compose up -d && exit"

- name: Cleanup
run: rm -rf ~/.ssh
run: rm -rf ~/.ssh

- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'success'

- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: '${{ github.token }}'
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: 'failure'

0 comments on commit 184763e

Please sign in to comment.