fix docker image building
This commit is contained in:
@@ -11,36 +11,24 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
path: .
|
||||
|
||||
- name: Transfer files
|
||||
uses: burnett01/rsync-deployments@8.0.4
|
||||
- name: Copy docker-compose.yml to server
|
||||
uses: appleboy/scp-action@v0.1.7
|
||||
with:
|
||||
switches: -azvr --delete --exclude=".gitignore" --exclude=".git" --exclude=".gitea" --exclude="data" --exclude=".env"
|
||||
path: .
|
||||
remote_path: /home/${{ secrets.USERNAME }}/minecraft-server-ironveil
|
||||
remote_host: ${{ secrets.HOST }}
|
||||
remote_user: ${{ secrets.USERNAME }}
|
||||
remote_key: ${{ secrets.KEY }}
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
source: "compose-file/docker-compose.yml"
|
||||
target: "/home/${{ secrets.USERNAME }}/minecraft-server-ironveil"
|
||||
strip_components: 1
|
||||
|
||||
- name: Stop container
|
||||
- name: Deploy and restart container
|
||||
uses: appleboy/ssh-action@v1.2.5
|
||||
with:
|
||||
host: ${{ secrets.host }}
|
||||
host: ${{ secrets.HOST }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
script: |
|
||||
cd minecraft-server-ironveil
|
||||
docker compose down
|
||||
|
||||
- name: Start container
|
||||
uses: appleboy/ssh-action@v1.2.5
|
||||
with:
|
||||
host: ${{ secrets.host }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
key: ${{ secrets.KEY }}
|
||||
script: |
|
||||
cd minecraft-server-ironveil
|
||||
docker compose up -d
|
||||
docker compose pull
|
||||
docker compose up -d --force-recreate
|
||||
|
||||
@@ -2,29 +2,45 @@ name: Build and Publish Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v[0-9]+.[0-9]+.[0-9]+
|
||||
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to git.cashew.network registry
|
||||
|
||||
- name: Log in to Docker Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: git.cashew.network
|
||||
username: ${{ secrets.GIT_USERNAME }}
|
||||
password: ${{ secrets.GIT_PASSWORD }}
|
||||
|
||||
- name: Build and push image
|
||||
registry: ${{ secrets.GIT_HOST }}
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Extract metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ secrets.GIT_HOST }}/${{ github.repository }}
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=raw,value=latest
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ secrets.GIT_USERNAME }}/ironveil:${{ github.ref_name }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=registry,ref=${{ secrets.GIT_HOST }}/${{ github.repository }}:buildcache
|
||||
cache-to: type=registry,ref=${{ secrets.GIT_HOST }}/${{ github.repository }}:buildcache,mode=max
|
||||
|
||||
Reference in New Issue
Block a user