chore : Update release dev workflows #16
Workflow file for this run
This file contains hidden or 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: Release Dev | |
| on: | |
| push: | |
| tags: | |
| - "*-dev.*" | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAMESPACE: hervibest | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set version from tag | |
| run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV | |
| - name: Login to GitHub Container Registry | |
| run: | | |
| echo "${{ secrets.REGISTRY_PASSWORD }}" | \ | |
| sudo docker login $REGISTRY \ | |
| -u ${{ secrets.REGISTRY_USERNAME }} \ | |
| --password-stdin | |
| # ====================== | |
| # photo-svc | |
| # ====================== | |
| - name: Build & Push photo-svc | |
| run: | | |
| sudo docker build \ | |
| -f photo-svc/Dockerfile \ | |
| -t $REGISTRY/$IMAGE_NAMESPACE/photo-svc:$VERSION . | |
| sudo docker push $REGISTRY/$IMAGE_NAMESPACE/photo-svc:$VERSION | |
| # ====================== | |
| # upload-svc | |
| # ====================== | |
| - name: Build & Push upload-svc | |
| run: | | |
| sudo docker build \ | |
| -f upload-svc/Dockerfile \ | |
| -t $REGISTRY/$IMAGE_NAMESPACE/upload-svc:$VERSION . | |
| sudo docker push $REGISTRY/$IMAGE_NAMESPACE/upload-svc:$VERSION | |
| # ====================== | |
| # user-svc | |
| # ====================== | |
| - name: Build & Push user-svc | |
| run: | | |
| sudo docker build \ | |
| -f user-svc/Dockerfile \ | |
| -t $REGISTRY/$IMAGE_NAMESPACE/user-svc:$VERSION . | |
| sudo docker push $REGISTRY/$IMAGE_NAMESPACE/user-svc:$VERSION | |
| # ====================== | |
| # transaction-svc | |
| # ====================== | |
| - name: Build & Push transaction-svc | |
| run: | | |
| sudo docker build \ | |
| -f transaction-svc/Dockerfile \ | |
| -t $REGISTRY/$IMAGE_NAMESPACE/transaction-svc:$VERSION . | |
| sudo docker push $REGISTRY/$IMAGE_NAMESPACE/transaction-svc:$VERSION | |
| # ====================== | |
| # notification-svc | |
| # ====================== | |
| - name: Build & Push notification-svc | |
| run: | | |
| sudo docker build \ | |
| -f notification-svc/Dockerfile \ | |
| -t $REGISTRY/$IMAGE_NAMESPACE/notification-svc:$VERSION . | |
| sudo docker push $REGISTRY/$IMAGE_NAMESPACE/notification-svc:$VERSION | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build-and-push | |
| steps: | |
| - name: Setup SSH agent | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.VPS_SSH_KEY }} | |
| - name: Deploy to VPS | |
| run: | | |
| ssh -o StrictHostKeyChecking=no \ | |
| ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} << EOF | |
| set -e | |
| cd /app/be-yourmoments-backup | |
| echo "APP_VERSION=${GITHUB_REF_NAME}" > .env | |
| sudo docker login ghcr.io -u hervibest -p "${{ secrets.REGISTRY_PASSWORD }}" | |
| sudo docker compose -f docker-compose-dev.yaml pull | |
| sudo docker compose -f docker-compose-dev.yaml down | |
| sudo docker compose -f docker-compose-dev.yaml up -d | |
| sudo docker image prune -f | |
| EOF | |