forked from CommunitySolidServer/CommunitySolidServer
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (88 loc) · 3.31 KB
/
docker.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
name: Docker
on:
workflow_call:
secrets:
DOCKERHUB_TOKEN:
required: true
DOCKERHUB_USERNAME:
required: true
jobs:
docker-meta:
# Generates the metadata (labels and tags) for the docker containers
# - push to main results in the edge tag
# - version tag results in edge, latest and semver, major, major.minor tags
# - push to versions/ results in the next tag
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.meta-main.outputs.labels || steps.meta-version.outputs.labels }}
tags: ${{ steps.meta-main.outputs.tags || steps.meta-version.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- if: startsWith(github.ref, 'refs/tags/v') || (github.ref == 'refs/heads/main')
name: Docker meta edge and version tag
id: meta-main
uses: docker/metadata-action@v5
with:
images: |
solidproject/community-server
# edge will always be executed (without latest tag), semver only on tag push events (with latest tag)
tags: |
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
github-token: ${{ secrets.github_token }}
- if: startsWith(github.ref, 'refs/heads/versions/')
name: Docker meta next
id: meta-version
uses: docker/metadata-action@v5
with:
images: |
solidproject/community-server
# Just one label: next (no latest here) for the last pushed commit on this branch
tags: |
type=raw,value=next
github-token: ${{ secrets.github_token }}
docker:
# Builds, tests and pushes docker containers
# Containers are built for both linux/amd64 and linux/arm/v7 platforms
needs: docker-meta
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and export to docker
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: ${{ needs.docker-meta.outputs.tags }}
labels: ${{ needs.docker-meta.outputs.labels }}
- name: "Test all docker-built image tags"
shell: bash
# Loop over all generated image:tag names and docker run them.
# If they aren't built previously, the command will error.
# If they don't work, the job will fail.
# If they work the --version argument should return a version and the job succeeds.
run: |
while read i; do
docker run --rm --pull never $i --version
done <<< "${{ needs.docker-meta.outputs.tags }}";
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64,linux/arm/v7,linux/arm/v8,linux/arm64/v8
tags: ${{ needs.docker-meta.outputs.tags }}
labels: ${{ needs.docker-meta.outputs.labels }}