mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
54 lines
1.3 KiB
YAML
54 lines
1.3 KiB
YAML
name: CI/CD Workflow
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v2
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/linux-odyssey:latest
|
|
|
|
deploy:
|
|
needs: build-and-push
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout Tailscale Action
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: 'tsujamin/tailscale-github-action'
|
|
path: '.github/actions/tailscale'
|
|
|
|
- name: Setup Tailscale VPN
|
|
uses: ./.github/actions/tailscale
|
|
with:
|
|
authkey: ${{ secrets.TAILSCALE_AUTH_KEY }}
|
|
|
|
- name: SSH into server and update service
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
script: |
|
|
cd ${{ secrets.SERVER_PATH }}
|
|
docker compose pull
|
|
docker compose up -d
|