Update main.yml

This commit is contained in:
Vu Quoc Anh
2024-12-30 11:52:34 +07:00
committed by GitHub
parent 590fbec630
commit 68a2efd69f

View File

@@ -51,6 +51,9 @@ jobs:
- name: Check out the repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
@@ -58,27 +61,16 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build the Docker image
- name: Build and push Docker image with caching
run: |
IMAGE_NAME=ghcr.io/coder-vippro/chatgpt-discord-bot
IMAGE_TAG=latest
docker build --cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
-t $IMAGE_NAME:$IMAGE_TAG .
- name: Push the Docker image
run: |
IMAGE_NAME=ghcr.io/coder-vippro/chatgpt-discord-bot
IMAGE_TAG=latest
docker push $IMAGE_NAME:$IMAGE_TAG
docker buildx build \
--cache-from=type=gha \
--cache-to=type=gha,mode=max \
--push \
-t $IMAGE_NAME:$IMAGE_TAG .
# Deploy from GHCR to the main server
deploy:
@@ -93,14 +85,6 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Docker layers on server
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Remove old running container
run: |
docker rm -f chatgpt-discord-bot || true