-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
150 lines (134 loc) · 5.35 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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Docker
on:
pull_request:
push:
branches:
- master
merge_group:
release:
types:
- published
permissions:
contents: read
defaults:
run:
shell: bash -xeuo pipefail {0}
jobs:
ubuntu:
if: github.repository_owner == 'Homebrew'
name: docker (Ubuntu ${{ matrix.version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["18.04", "20.04", "22.04", "24.04"]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
persist-credentials: false
- name: Fetch origin/master from Git
run: git fetch origin master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: Determine build attributes
id: attributes
run: |
date="$(date --rfc-3339=seconds --utc)"
brew_version="$(git describe --tags --dirty --abbrev=7)"
DELIMITER="END_LABELS_$(uuidgen)"
cat <<EOS | tee -a "${GITHUB_OUTPUT}"
labels<<${DELIMITER}
org.opencontainers.image.created=${date}
org.opencontainers.image.url=https://brew.sh
org.opencontainers.image.documentation=https://docs.brew.sh
org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}
org.opencontainers.image.version=${brew_version}
org.opencontainers.image.revision=${GITHUB_SHA}
org.opencontainers.image.vendor=${GITHUB_REPOSITORY_OWNER}
org.opencontainers.image.licenses=BSD-2-Clause
${DELIMITER}
EOS
tags=()
if [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
tags+=(
"ghcr.io/homebrew/ubuntu${{matrix.version}}:${brew_version}"
"ghcr.io/homebrew/ubuntu${{matrix.version}}:latest"
"homebrew/ubuntu${{matrix.version}}:${brew_version}"
"homebrew/ubuntu${{matrix.version}}:latest"
)
if [[ "${{ matrix.version }}" == "22.04" ]]; then
tags+=(
"ghcr.io/homebrew/brew:${brew_version}"
"ghcr.io/homebrew/brew:latest"
"homebrew/brew:${brew_version}"
"homebrew/brew:latest"
)
fi
elif [[ "${GITHUB_EVENT_NAME}" == "push" &&
"${GITHUB_REF}" == "refs/heads/master" &&
"${{ matrix.version }}" == "22.04" ]]; then
tags+=(
"ghcr.io/homebrew/brew:master"
"ghcr.io/homebrew/ubuntu${{ matrix.version }}:master"
"homebrew/brew:master"
"homebrew/ubuntu${{matrix.version}}:master"
)
fi
if [[ "${{ matrix.version }}" == "18.04" ]]; then
# odeprecated: remove this in Homebrew >=4.4
echo "The homebrew/ubuntu18.04 image is deprecated and will soon be retired. Use homebrew/ubuntu22.04 or homebrew/ubuntu24.04 or homebrew/ubuntu20.04 or homebrew/brew." > .docker-deprecate
fi
{
if [[ "${#tags[@]}" -ne 0 ]]; then
DELIMITER="END_TAGS_$(uuidgen)"
echo "tags<<${DELIMITER}"
printf "%s\n" "${tags[@]}"
echo "${DELIMITER}"
echo "push=true"
else
echo "push=false"
fi
} | tee -a "${GITHUB_OUTPUT}"
- name: Log in to GitHub Packages (github-actions[bot])
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: github-actions[bot]
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with:
context: .
load: true
tags: brew
cache-from: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache
build-args: version=${{ matrix.version }}
labels: ${{ steps.attributes.outputs.labels }}
- name: Run brew test-bot --only-setup
run: docker run --rm brew brew test-bot --only-setup
- name: Log in to GitHub Packages (BrewTestBot)
if: steps.attributes.outputs.push == 'true'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
registry: ghcr.io
username: BrewTestBot
password: ${{ secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN }}
- name: Log in to Docker Hub
if: steps.attributes.outputs.push == 'true'
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: brewtestbot
password: ${{ secrets.HOMEBREW_BREW_DOCKER_TOKEN }}
- name: Deploy the tagged Docker image
if: steps.attributes.outputs.push == 'true'
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with:
context: .
push: true
tags: ${{ steps.attributes.outputs.tags }}
cache-from: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache
cache-to: type=registry,ref=ghcr.io/homebrew/ubuntu${{ matrix.version }}:cache,mode=max
build-args: version=${{ matrix.version }}
labels: ${{ steps.attributes.outputs.labels }}