diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 2fd6a85..8a22630 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -16,13 +16,18 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Docker Buildx + - name: Settle up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Log in to Github Container Registry + - name: Authenticating to Eden Server realms. + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SERVER_PRIVATE_KEY }} + + - name: Authenticating to GHCR realms run: echo "${{ secrets.GH_TOKEN }}" | docker login -u "${{ github.actor }}" ghcr.io --password-stdin - - name: Build Docker image + - name: Treaty Build the Docker image run: | docker build \ --build-arg PORT=3121 \ @@ -43,12 +48,30 @@ jobs: --build-arg CLOUDINARY_API_SECRET=${{ secrets.CLOUDINARY_API_SECRET }} \ -t ghcr.io/xyzuan/xyzuan_api_v2:dev -f misc/Dockerfile.dev . - - name: Tag Docker image + - name: Adding tags to the Images run: | IMAGE_NAME=ghcr.io/xyzuan/xyzuan_api_v2 docker tag $IMAGE_NAME:dev $IMAGE_NAME:$(echo "${{ github.sha }}" | head -c 7) - - name: Push Docker image + - name: Bring the Images to GHCR run: | docker push ghcr.io/xyzuan/xyzuan_api_v2:dev docker push ghcr.io/xyzuan/xyzuan_api_v2:$(echo "${{ github.sha }}" | head -c 7) + + - name: Serving the Images in Eden Server realms. + run: | + ssh-keyscan -t rsa ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts + ssh ${{ github.actor }}@${{ secrets.SERVER_HOST }} << 'EOF' + + echo 'Authenticating to GHCR realms...' + echo "${{ secrets.GH_TOKEN }}" | docker login -u "${{ github.actor }}" ghcr.io --password-stdin + + echo 'Pulling the latest image from GHCR...' + docker pull ghcr.io/xyzuan/xyzuan_api_v2:dev + + echo 'Force Blowing the exist Docker Container...' + docker rm -f xyzuan-api-v2-dev + + echo 'Running the Docker Container...' + docker run -d -p 61131:3121 --name xyzuan-api-v2-dev ghcr.io/xyzuan/xyzuan_api_v2:dev + EOF