7
7
env :
8
8
CheckFiles : " bot.py musicbot/"
9
9
steps :
10
- - uses : actions/checkout@v2
10
+ - uses : actions/checkout@v3
11
11
12
12
- name : Set up Python 3.10
13
- uses : actions/setup-python@v4.2 .0
13
+ uses : actions/setup-python@v4.5 .0
14
14
with :
15
15
python-version : 3.10.7
16
16
@@ -27,14 +27,14 @@ jobs:
27
27
test :
28
28
runs-on : ubuntu-latest
29
29
steps :
30
- - uses : actions/checkout@v2
30
+ - uses : actions/checkout@v3
31
31
32
32
- name : Set up Python 3.10
33
- uses : actions/setup-python@v4.2 .0
33
+ uses : actions/setup-python@v4.5 .0
34
34
with :
35
35
python-version : 3.10.7
36
36
37
- - name : Install dependencies
37
+ - name : Install dependencies
38
38
run : |
39
39
pip install pytest
40
40
pip install -r requirements.txt
@@ -45,57 +45,118 @@ jobs:
45
45
46
46
build-and-push :
47
47
needs : [lint, test]
48
+ strategy :
49
+ matrix :
50
+ architecture : [linux-arm-v7, linux-arm64, linux-amd64]
48
51
runs-on : ubuntu-latest
49
52
if : github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true'
50
- env :
51
- DOCKER_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
52
53
53
54
steps :
54
- - uses : actions/checkout@v2
55
+ - uses : actions/checkout@v3
56
+
57
+ - name : Set up QEMU
58
+
59
+
60
+ - name : Set up Docker Buildx
61
+
62
+ with :
63
+ install : true
64
+ version : latest
65
+ driver-opts : image=moby/buildkit:master
66
+
67
+ - name : Login to DockerHub
68
+
69
+ with :
70
+ username : roxedus
71
+ password : ${{ secrets.DOCKER_HUB_PASSWORD }}
72
+
73
+ - name : Login to GitHub Container Registry
74
+
75
+ with :
76
+ registry : ghcr.io
77
+ username : ${{ github.actor }}
78
+ password : ${{ secrets.GITHUB_TOKEN }}
55
79
56
80
- name : Create VARS
57
- env :
58
- _repo : rnorge/music
59
- _username : roxedus
60
- _ref : ${{github.ref}}
61
81
id : vars
62
82
run : |
63
- echo "::set-output name=branch::$(echo ${_ref} | cut -d/ -f3)"
64
- echo "::set-output name=username::$(echo ${_username} | cut -d/ -f1 | tr '[:upper:]' '[:lower:]')"
65
- echo "::set-output name=repo::$(echo ${_repo} | tr '[:upper:]' '[:lower:]')"
83
+ ARCHITECTURE=${{ matrix.architecture }}
84
+ echo "branch=$(echo ${{github.ref}} | cut -d/ -f3)" >> $GITHUB_OUTPUT
85
+ echo "repo=rnorge/music" >> $GITHUB_OUTPUT
86
+ echo "platform=${ARCHITECTURE//-/\/}" >> $GITHUB_OUTPUT
87
+ echo "ghcr=r-norge/shitemusicbot" >> $GITHUB_OUTPUT
88
+ echo "version=$(grep -i bot_version musicbot/utils/bot_version.py | cut -d" " -f3 | tr -d \")" >> $GITHUB_OUTPUT
89
+
90
+ - name : Build and push
91
+
92
+ with :
93
+ push : true
94
+ attests : type=sbom,generator=docker/buildkit-syft-scanner
95
+ # sbom: true
96
+ provenance : true # https://github.com/docker/buildx/issues/1509
97
+ platforms : ${{ steps.vars.outputs.platform }}
98
+ build-args : BUILDKIT_SBOM_SCAN_CONTEXT=true,BUILDKIT_SBOM_SCAN_STAGE=true
99
+ tags : |
100
+ ${{ steps.vars.outputs.repo }}:${{ steps.vars.outputs.branch }}-${{github.sha}}-${{ matrix.architecture }}
101
+ ghcr.io/${{ steps.vars.outputs.ghcr }}:${{ steps.vars.outputs.branch }}-${{github.sha}}-${{ matrix.architecture }}
102
+
103
+ publish :
104
+ needs : [build-and-push]
105
+ runs-on : ubuntu-latest
106
+ if : github.event_name != 'pull_request' && contains(github.ref, 'actions') != 'true'
66
107
67
- - name : Push changed files, and tags
68
- if : github.ref == 'refs/heads/master'
69
- uses : EndBug/add-and-commit@v4
108
+ steps :
109
+ - uses : actions/checkout@v3
110
+
111
+ - name : Set up Docker Buildx
112
+
70
113
with :
71
- add : musicbot/utils/bot_version.py
72
- author_name : MarlinBotCode
73
- message : Bump Version
74
- tag : v${{ steps.tagger.outputs.tag }}
75
- env :
76
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
114
+ install : true
115
+ version : latest
116
+ driver-opts : image=moby/buildkit:master
77
117
78
- - name : Build the Docker image
79
- env :
80
- REPO : ${{ steps.vars.outputs.repo }}
81
- BRANCH : ${{ steps.vars.outputs.branch }}
118
+ - name : Login to DockerHub
119
+
120
+ with :
121
+ username : roxedus
122
+ password : ${{ secrets.DOCKER_HUB_PASSWORD }}
123
+
124
+ - name : Login to GitHub Container Registry
125
+
126
+ with :
127
+ registry : ghcr.io
128
+ username : ${{ github.actor }}
129
+ password : ${{ secrets.GITHUB_TOKEN }}
130
+
131
+ - name : Create VARS
132
+ id : vars
82
133
run : |
83
- docker build -t $REPO:$BRANCH -t $REPO:$BRANCH-${{github.sha}} .
134
+ echo "branch=$(echo ${{github.ref}} | cut -d/ -f3)" >> $GITHUB_OUTPUT
135
+ echo "repo=rnorge/music" >> $GITHUB_OUTPUT
136
+ echo "ghcr=r-norge/shitemusicbot" >> $GITHUB_OUTPUT
137
+ echo "version=$(grep -i bot_version musicbot/utils/bot_version.py | cut -d" " -f3 | tr -d \")" >> $GITHUB_OUTPUT
84
138
85
- - name : Master tag
86
- if : github.ref == 'refs/heads/master'
139
+ - name : Create manifests for DockerHub
87
140
env :
88
- REPO : ${{ steps.vars.outputs.repo }}
89
- BRANCH : ${{ steps.vars.outputs.branch }}
141
+ DOCKER_CLI_EXPERIMENTAL : enabled
90
142
run : |
91
- docker tag $REPO:$BRANCH $REPO:${{ steps.tagger.outputs.tag }}
92
-
93
- - name : Login to registry
94
- if : github.event_name != 'pull_request'
95
- run : echo $DOCKER_PASSWORD | docker login -u ${{ steps.vars.outputs.username }} --password-stdin
96
-
97
- - name : Pushes the Docker image
143
+ IMAGE=${{ steps.vars.outputs.repo }}
144
+ TAG=${{ steps.vars.outputs.branch }}-${{github.sha}}
145
+ SOURCE=${IMAGE}:${TAG}
146
+ docker buildx imagetools create -t ${SOURCE} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
147
+ docker buildx imagetools create -t ${IMAGE}:${{ steps.vars.outputs.branch }} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
148
+ if [[ ${GITHUB_REF//refs\/heads\//} == master ]]; then
149
+ docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
150
+ fi
151
+ - name : Create manifests for GitHub Container Registry
98
152
env :
99
- REPO : ${{ steps.vars.outputs.repo }}
100
- if : github.event_name != 'pull_request'
101
- run : docker push -a $REPO
153
+ DOCKER_CLI_EXPERIMENTAL : enabled
154
+ run : |
155
+ IMAGE=ghcr.io/${{ steps.vars.outputs.ghcr }}
156
+ TAG=${{ steps.vars.outputs.branch }}-${{github.sha}}
157
+ SOURCE=${IMAGE}:${TAG}
158
+ docker buildx imagetools create -t ${SOURCE} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
159
+ docker buildx imagetools create -t ${IMAGE}:${{ steps.vars.outputs.branch }} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
160
+ if [[ ${GITHUB_REF//refs\/heads\//} == master ]]; then
161
+ docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm-v7 ${SOURCE}-linux-arm64
162
+ fi
0 commit comments