Skip to content

Update workflow

Update workflow #11

Workflow file for this run

name: Build and Deploy on Push
on:
push:
branches:
- master
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and Push Docker Image
run: |
COMMIT_HASH=$(echo $GITHUB_SHA | cut -c1-7)
docker buildx create --use
docker buildx build --platform linux/amd64,linux/arm64 \
-t devinfritz/vzbot-web-nuxt:stage-${COMMIT_HASH} --push .
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Add server's SSH private key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
- name: Add server's SSH public key to known_hosts
run: |
mkdir -p ~/.ssh
echo "${{ secrets.SERVER_PUBLIC_KEY }}" >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Deploy application
run: |
ssh -i ~/.ssh/id_ed25519 -p ${{secrets.SERVER_SSH_PORT}} ${{secrets.SERVER_SSH_USERNAME}}@${{secrets.SERVER_HOST}} "your deployment commands here"