mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
Add github action
This commit is contained in:
1 parent
2dffd2f74d
commit
6d8163f6a6
1 file changed
+53
@@ -0,0 +1,53 @@
|
||||
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
|
||||
Reference in new issue
Block a user