-
Notifications
You must be signed in to change notification settings - Fork 13
94 lines (91 loc) · 3.18 KB
/
build-container.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: Build container
on:
pull_request:
push:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-20.04
env:
ANOPE_VERSION: 2.0.13
DOCKER_REPO: anope/anope
GITHUB_BRANCH: master
GITHUB_REPO: anope/anope-docker
steps:
-
uses: actions/checkout@v3
-
name: Test base image and code version
run: |
ls tests/*.sh | parallel --joblog /tmp/joblog
cat /tmp/joblog
env:
VERSION: ${{ env.ANOPE_VERSION }}
-
name: Pipeline variables
id: pipeline_vars
run: |
EXPECTED="$GITHUB_REPO $GITHUB_BRANCH"
echo "Expected: $EXPECTED"
ACTUAL="${{ github.repository }} ${{ github.ref_name }}"
echo "Actual: $ACTUAL"
if [ "$EXPECTED" == "$ACTUAL" ]
then
echo "On $GITHUB_REPO repo, $GITHUB_BRANCH branch - building all architectures and pushing to Docker Hub"
echo "push=true" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT
else
echo "Not on $GITHUB_REPO repo and $GITHUB_BRANCH branch - only building amd64 architecture and not pushing to Docker Hub"
echo "push=false" >> $GITHUB_OUTPUT
echo "platforms=linux/amd64" >> $GITHUB_OUTPUT
fi
-
name: Prepare environment
run: |
sudo apt-get -qq update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install moby-engine moby-cli
sudo apt-get install -y openssl parallel
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKER_REPO }}
tags: |
type=semver,pattern={{version}},value=${{ env.ANOPE_VERSION }}
type=semver,pattern={{major}}.{{minor}},value=${{ env.ANOPE_VERSION }}
type=semver,pattern={{major}},value=${{ env.ANOPE_VERSION }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Log in to Docker Hub
if: github.repository == env.GITHUB_REPO && github.ref_name == env.GITHUB_BRANCH
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
context: .
build-args: VERSION=${{ env.ANOPE_VERSION }}
platforms: ${{ steps.pipeline_vars.outputs.platforms }}
push: ${{ steps.pipeline_vars.outputs.push }}
tags: ${{ steps.meta.outputs.tags }}
-
name: Update description on Docker Hub
if: github.repository == env.GITHUB_REPO && github.ref_name == env.GITHUB_BRANCH
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
repository: ${{ env.DOCKER_REPO }}
short-description: Anope IRC Services https://anope.org
readme-filepath: README.md