chore: Add CD to CI

This commit is contained in:
Felix Dürrwald 2024-06-12 21:16:39 +02:00
parent bc19131a0a
commit 15c306123e
Signed by: mplabs
GPG Key ID: 6E7D7F464AC5179D
2 changed files with 24 additions and 35 deletions

View File

@ -1,20 +0,0 @@
name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
Explore-Gitea-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."

View File

@ -13,21 +13,30 @@ jobs:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Docker Buildx 🚀
uses: docker/setup-buildx-action@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
since_last_remote_commit: true
separator: ","
- name: Login to Docker Hub 🚢
uses: docker/login-action@v3
- name: Copy repository contents
uses: appleboy/scp-action@0.1.7
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
host: ${{ secrets.HOST }}
port: ${{ secrets.PORT }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
source: ${{ steps.changed-files.outputs.all_changed_files }}
target: ${{ secrets.REMOTE_PATH }}
- name: Build and push 🏗️
uses: docker/build-push-action@v2
- name: Restart remote application
uses: appleboy/ssh-action@1.0.3
with:
context: .
file: ./Dockerfile
push: false
# tags: |
# ${{ secrets.DOCKER_HUB_USERNAME}}/{docker_repository}:${{ github.sha }}
# ${{ secrets.DOCKER_HUB_USERNAME}}/{docker_repository}:latest
host: ${{ inputs.host }}
port: ${{ inputs.port }}
username: ${{ inputs.username }}
key: ${{ secrets.KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
script: cd ${{ secrets.remote-path }} && docker build . && docker run -p 3000:3000