-
Notifications
You must be signed in to change notification settings - Fork 87
67 lines (57 loc) · 1.81 KB
/
Build Docker 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
67
name: Build Docker Image
on:
push:
tags:
- 'release-v*'
workflow_dispatch:
env:
GHCR_REPO: ghcr.io/aurorax-neo/free-gpt3.5-2api
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Docker Image Tag
shell: bash
id: get_docker_image_tag
run: echo "tag=$(echo $GITHUB_REF | sed 's|refs/tags/release-v||')" >> $GITHUB_OUTPUT
- name: Set Up QEMU
uses: docker/setup-qemu-action@v3
- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login To GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GB_TOKEN }}
- name: Cache Docker Layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: "${{ runner.os }}-buildx-${{ github.sha }}"
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker Image And Push To GHCR
uses: docker/build-push-action@v5
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
file: Dockerfile
tags: |
${{ env.GHCR_REPO }}:latest
${{ env.GHCR_REPO }}:${{ steps.get_docker_image_tag.outputs.tag }}
${{ env.GHCR_REPO }}:${{ github.sha }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max
- name: Delete Workflow Runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ secrets.GB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 8