Skip to content

Commit

Permalink
Merge pull request #41 from sudeeppr1998/all-1.3-staging
Browse files Browse the repository at this point in the history
All staging workflow added to 1.3
  • Loading branch information
sudeeppr1998 authored Oct 14, 2024
2 parents 096f7bd + 9e9d5eb commit f11e7ae
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: STAGING DEPLOYMENT

on:
push:
branches: [ all-1.3-staging ]

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME_DEVOPS }}
password: ${{ secrets.DOCKERHUB_TOKEN_DEVOPS }}

-
name: Load .env from GitHub Secret
run: echo "${{ secrets.MY_ENV_VARS_STAGING }}" > .env

-
name: Build and push
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
env:
MY_ENV_VARS: ${{ secrets.MY_ENV_VARS_STAGING }}
deploy:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: [build]
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.PORT }}
script: |
ssh -i ~/.ssh/all_staging_key.pem ${{ secrets.USERNAME_STAGING }}@${{ secrets.HOST_STAGING }} 'bash -s' << 'EOF'
docker login
docker container stop ${{ secrets.CONTAINER_NAME }}
docker rm ${{ secrets.CONTAINER_NAME }}
docker rmi ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
docker pull ${{ secrets.CONTAINER_REGISTRY_STAGING }}:${{ secrets.IMAGE_TAG }}
cd /home/all-staging-user/all-services/all-content-service
sudo docker-compose up -d --force-recreate --no-deps
EOF

0 comments on commit f11e7ae

Please sign in to comment.