Build and deploy backend core on server #40
This file contains 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: Build and deploy backend core on server | ||
on: | ||
push: | ||
paths: | ||
- 'backend/**' | ||
branches: | ||
- deploy | ||
workflow_dispatch: | ||
jobs: | ||
docker: | ||
name: Build and Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- | ||
name: Build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: backend/ | ||
push: false | ||
load: true | ||
tags: ghcr.io/marcindz88/jetlag/jetlag-core:latest | ||
platforms: linux/amd64 | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | ||
- | ||
# Temp fix | ||
# https://github.com/docker/build-push-action/issues/252 | ||
# https://github.com/moby/buildkit/issues/1896 | ||
name: Move cache | ||
run: | | ||
rm -rf /tmp/.buildx-cache | ||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache | ||
- | ||
name: Push docker image to registry | ||
run: | | ||
Check failure on line 50 in .github/workflows/deploy-backend.yml GitHub Actions / Build and deploy backend core on serverInvalid workflow file
|
||
docker login ghcr.io -u marcindz88 --password ${{GH_TOKEN}} | ||
docker push ghcr.io/marcindz88/jetlag/jetlag-core:latest | ||
env: | ||
SERVER_SSH_KEY: ${{secrets.SERVER_SSH_KEY}} | ||
GH_TOKEN: ${{secrets.GH_TOKEN}} | ||
- | ||
name: Rollout restart image on the server | ||
run: | | ||
echo "$SERVER_SSH_KEY" > private.key | ||
chmod 400 private.key | ||
ssh -i private.key -o StrictHostKeyChecking=no root@${{secrets.SERVER_IP}} "kubectl rollout restart deployment/jetlag-core -n jetlag" | ||
env: | ||
SERVER_IP: ${{secrets.SERVER_IP}} | ||
SERVER_SSH_KEY: ${{secrets.SERVER_SSH_KEY}} |