-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (56 loc) · 1.84 KB
/
deploy-image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Deploy Docker Image
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: write
jobs:
build-and-push:
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 GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check for existing cache
id: cache-check
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ hashFiles('Dockerfile', 'requirements.txt') }}
- name: Delete old caches if no cache found
if: steps.cache-check.outputs.cache-hit != 'true'
env:
GH_TOKEN: ${{ secrets.FOR_CACHE_REPO_PAT }}
run: |
if gh cache list --repo probablyjassin/bot-mk8dx | grep -q 'buildx'; then
gh cache delete --all --repo probablyjassin/bot-mk8dx
else
echo "No caches to delete."
fi
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: |
/tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.ref }}-${{ hashFiles('Dockerfile', 'requirements.txt') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/probablyjassin/mk8dx-yuzu-bot:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache