Update main.yml
This commit is contained in:
34
.github/workflows/main.yml
vendored
34
.github/workflows/main.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user