|
1 | | -name: 🚀 Deploy VectoBeat |
| 1 | +name: 🚀 Release & Publish |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | 5 | types: [published] |
6 | 6 | workflow_dispatch: |
7 | 7 |
|
| 8 | +env: |
| 9 | + REGISTRY: ghcr.io |
| 10 | + IMAGE_NAME: ${{ github.repository }} |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: read |
| 14 | + packages: write |
| 15 | + |
8 | 16 | jobs: |
| 17 | + publish-image: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Extract metadata (tags, labels) |
| 24 | + id: meta |
| 25 | + uses: docker/metadata-action@v5 |
| 26 | + with: |
| 27 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 28 | + tags: | |
| 29 | + type=ref,event=release |
| 30 | + type=ref,event=tag |
| 31 | + type=raw,value=latest |
| 32 | +
|
| 33 | + - name: Set up Docker Buildx |
| 34 | + uses: docker/setup-buildx-action@v3 |
| 35 | + |
| 36 | + - name: Log in to GitHub Container Registry |
| 37 | + uses: docker/login-action@v3 |
| 38 | + with: |
| 39 | + registry: ${{ env.REGISTRY }} |
| 40 | + username: ${{ github.actor }} |
| 41 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Build and push image |
| 44 | + uses: docker/build-push-action@v5 |
| 45 | + with: |
| 46 | + context: . |
| 47 | + file: Dockerfile |
| 48 | + push: true |
| 49 | + tags: ${{ steps.meta.outputs.tags }} |
| 50 | + labels: ${{ steps.meta.outputs.labels }} |
| 51 | + |
9 | 52 | deploy: |
| 53 | + needs: publish-image |
10 | 54 | runs-on: ubuntu-latest |
| 55 | + if: ${{ secrets.DEPLOY_SSH_HOST != '' && secrets.DEPLOY_SSH_USER != '' && secrets.DEPLOY_SSH_KEY != '' && secrets.DEPLOY_TARGET_PATH != '' }} |
11 | 56 | steps: |
12 | | - - uses: actions/checkout@v4 |
| 57 | + - name: Sync container to server |
| 58 | + uses: appleboy/scp-action@v0.1.7 |
| 59 | + with: |
| 60 | + host: ${{ secrets.DEPLOY_SSH_HOST }} |
| 61 | + username: ${{ secrets.DEPLOY_SSH_USER }} |
| 62 | + key: ${{ secrets.DEPLOY_SSH_KEY }} |
| 63 | + source: docker-compose.yml |
| 64 | + target: ${{ secrets.DEPLOY_TARGET_PATH }} |
13 | 65 |
|
14 | | - - name: Setup Python |
15 | | - uses: actions/setup-python@v5 |
| 66 | + - name: Trigger remote deployment |
| 67 | + uses: appleboy/ssh-action@v1.0.3 |
16 | 68 | with: |
17 | | - python-version: "3.11" |
18 | | - |
19 | | - - name: Install dependencies |
20 | | - run: | |
21 | | - python -m pip install --upgrade pip |
22 | | - pip install -r requirements.txt |
23 | | -
|
24 | | - - name: Deploy to Production |
25 | | - env: |
26 | | - DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} |
27 | | - LAVALINK_HOST: ${{ secrets.LAVALINK_HOST }} |
28 | | - LAVALINK_PORT: ${{ secrets.LAVALINK_PORT }} |
29 | | - LAVALINK_PASSWORD: ${{ secrets.LAVALINK_PASSWORD }} |
30 | | - run: | |
31 | | - echo "🚀 Deploying VectoBeat..." |
32 | | - python -m src.main |
| 69 | + host: ${{ secrets.DEPLOY_SSH_HOST }} |
| 70 | + username: ${{ secrets.DEPLOY_SSH_USER }} |
| 71 | + key: ${{ secrets.DEPLOY_SSH_KEY }} |
| 72 | + envs: REGISTRY,IMAGE_NAME,GITHUB_ACTOR,GITHUB_TOKEN |
| 73 | + env: |
| 74 | + REGISTRY: ${{ env.REGISTRY }} |
| 75 | + IMAGE_NAME: ${{ env.IMAGE_NAME }} |
| 76 | + GITHUB_ACTOR: ${{ github.actor }} |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + script: | |
| 79 | + docker login $REGISTRY -u "$GITHUB_ACTOR" -p "$GITHUB_TOKEN" |
| 80 | + cd ${{ secrets.DEPLOY_TARGET_PATH }} |
| 81 | + docker compose pull |
| 82 | + docker compose up -d --remove-orphans |
0 commit comments