forked from jimeh/docker-flexget
-
Notifications
You must be signed in to change notification settings - Fork 40
125 lines (122 loc) · 3.91 KB
/
buildx.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: buildx
on:
workflow_dispatch:
schedule:
- cron: "0 21 * * 5"
push:
branches:
- 'master'
env:
DOCKERHUB_USER: wiserain
IMAGE_NAME: wiserain/flexget
ALPINE_VER: '3.19'
jobs:
buildx:
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request'
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Compile requirements.txt
run: |
docker run --rm -i -v ${PWD}:/req alpine:${{ env.ALPINE_VER }} \
sh -c "apk add py3-pip build-base python3-dev libffi-dev && rm /usr/lib/python*/EXTERNALLY-MANAGED && pip install pip-tools && cd /req && pip-compile -U"
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Buildx
uses: docker/setup-buildx-action@v3
-
name: Initial Buildx
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: ${{ env.IMAGE_NAME }}:testing
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VER=${{ env.ALPINE_VER }}
-
name: Load Built Image and Get Variables
id: vars
run: |
docker buildx build \
-t ${{ env.IMAGE_NAME }}:testing \
--platform=linux/amd64 \
--build-arg ALPINE_VER=${{ env.ALPINE_VER }} \
--load \
.
CID=$(docker run -d ${{ env.IMAGE_NAME }}:testing)
VER_FULL=$(docker exec $CID flexget -V | sed -n 1p)
echo "VER_FULL=$VER_FULL" >> $GITHUB_ENV
docker rm -f $CID
VER_MINOR=$(echo $VER_FULL | cut -d. -f-2)
echo "VER_MINOR=$VER_MINOR" >> $GITHUB_ENV
VER_MAJOR=$(echo $VER_FULL | cut -d. -f-1)
echo "VER_MAJOR=$VER_MAJOR" >> $GITHUB_ENV
-
name: Login to docker.io
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
#
# release
#
-
name: Buildx and Push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.VER_FULL }}
${{ env.IMAGE_NAME }}:${{ env.VER_MINOR }}
${{ env.IMAGE_NAME }}:${{ env.VER_MAJOR }}
ghcr.io/${{ env.IMAGE_NAME }}:latest
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_FULL }}
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MINOR }}
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MAJOR }}
platforms: linux/amd64,linux/arm64
build-args: |
ALPINE_VER=${{ env.ALPINE_VER }}
push: true
-
name: Notification
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: ${{ job.status }}
description: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.VER_FULL }}
${{ env.IMAGE_NAME }}:${{ env.VER_MINOR }}
${{ env.IMAGE_NAME }}:${{ env.VER_MAJOR }}
ghcr.io/${{ env.IMAGE_NAME }}:latest
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_FULL }}
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MINOR }}
ghcr.io/${{ env.IMAGE_NAME }}:${{ env.VER_MAJOR }}
-
name: Commit requirements.txt
uses: EndBug/add-and-commit@v9
with:
message: |
Update requirements.txt
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: requirements.txt
path: requirements.txt