Update deploy.yml #18
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 push docker image and deploy | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Log in to Github Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/${{ github.actor }}/voltvector-fe:latest | |
deploy: | |
needs: build_and_push | |
if: ${{ success() }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: appleboy/[email protected] | |
name: Fetch and run deploy script on remote | |
with: | |
host: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USER }} | |
key: ${{ secrets.DEPLOY_KEY }} | |
port: 22 | |
script: | | |
curl -O https://raw.githubusercontent.com/pb-coding/voltvector-fe/main/.github/scripts/deploy.sh | |
chmod +x deploy.sh | |
./deploy.sh ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
rm deploy.sh |