Skip to content

Commit

Permalink
Merge pull request #18168 from Homebrew/docker-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcQuaid authored Aug 26, 2024
2 parents 70e777c + e7e244e commit abc0584
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 50 deletions.
50 changes: 37 additions & 13 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
name: Docker

on:
pull_request:
paths:
- .github/workflows/docker.yml
- Dockerfile
push:
paths:
- .github/workflows/docker.yml
- Dockerfile
branches-ignore:
branches:
- master
merge_group:
release:
types:
- published

permissions:
contents: read

jobs:
ubuntu:
if: startsWith(github.repository, 'Homebrew/')
if: github.repository_owner == 'Homebrew'
runs-on: ubuntu-22.04
strategy:
fail-fast: false
Expand Down Expand Up @@ -52,28 +50,44 @@ jobs:
- name: Run brew test-bot --only-setup
run: docker run --rm brew brew test-bot --only-setup

- name: Log in to GitHub Packages
if: >
github.event_name == 'release' ||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
run: |
docker login ghcr.io -u BrewTestBot --password-stdin <<<"$TOKEN"
env:
TOKEN: ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}}

- name: Log in to Docker Hub
if: >
github.event_name == 'release' ||
(github.event_name == 'push' && github.ref == 'refs/heads/master')
run: |
docker login -u brewtestbot --password-stdin <<<"$TOKEN"
env:
TOKEN: ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}}

- name: Deploy the tagged Docker image to GitHub Packages
if: startsWith(github.ref, 'refs/tags/')
if: github.event_name == 'release'
run: |
brew_version="${GITHUB_REF:10}"
echo "brew_version=${brew_version}" >> "${GITHUB_ENV}"
echo ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}} | docker login ghcr.io -u BrewTestBot --password-stdin
docker tag brew "ghcr.io/homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker push "ghcr.io/homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker tag brew "ghcr.io/homebrew/ubuntu${{matrix.version}}:latest"
docker push "ghcr.io/homebrew/ubuntu${{matrix.version}}:latest"
- name: Deploy the tagged Docker image to Docker Hub
if: startsWith(github.ref, 'refs/tags/')
if: github.event_name == 'release'
run: |
echo ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}} | docker login -u brewtestbot --password-stdin
docker tag brew "homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker push "homebrew/ubuntu${{matrix.version}}:${brew_version}"
docker tag brew "homebrew/ubuntu${{matrix.version}}:latest"
docker push "homebrew/ubuntu${{matrix.version}}:latest"
- name: Deploy the homebrew/brew Docker image to GitHub Packages and Docker Hub
if: startsWith(github.ref, 'refs/tags/') && matrix.version == '22.04'
if: github.event_name == 'release' && matrix.version == '22.04'
run: |
docker tag brew "ghcr.io/homebrew/brew:${brew_version}"
docker push "ghcr.io/homebrew/brew:${brew_version}"
Expand All @@ -83,3 +97,13 @@ jobs:
docker push "homebrew/brew:${brew_version}"
docker tag brew "homebrew/brew:latest"
docker push "homebrew/brew:latest"
- name: Deploy the homebrew/ubuntu22.04:master Docker image to GitHub Packages and Docker Hub
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.version == '22.04'
run: |
docker tag brew "ghcr.io/homebrew/ubuntu22.04:master"
docker push "ghcr.io/homebrew/ubuntu22.04:master"
docker tag brew "homebrew/ubuntu22.04:master"
docker push "homebrew/ubuntu22.04:master"
37 changes: 0 additions & 37 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,43 +211,6 @@ jobs:
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
run: git diff --stat --exit-code Library/Homebrew/vendor/bundle/ruby

docker:
needs: syntax
runs-on: ubuntu-22.04
steps:
- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: false
test-bot: false

- name: Build Docker image
working-directory: ${{ steps.set-up-homebrew.outputs.repository-path }}
run: |
docker build -t brew --build-arg=version=22.04 \
--label org.opencontainers.image.created="$(date --rfc-3339=seconds --utc)" \
--label org.opencontainers.image.url="https://brew.sh" \
--label org.opencontainers.image.documentation="https://docs.brew.sh" \
--label org.opencontainers.image.source="https://github.com/${GITHUB_REPOSITORY}" \
--label org.opencontainers.image.revision="${GITHUB_SHA}" \
--label org.opencontainers.image.vendor="${GITHUB_REPOSITORY_OWNER}" \
--label org.opencontainers.image.licenses="BSD-2-Clause" \
.
- name: Deploy the Docker image to GitHub Packages and Docker Hub
if: github.ref == 'refs/heads/master'
run: |
echo ${{secrets.HOMEBREW_BREW_GITHUB_PACKAGES_TOKEN}} |
docker login ghcr.io -u BrewTestBot --password-stdin
docker tag brew "ghcr.io/homebrew/ubuntu22.04:master"
docker push "ghcr.io/homebrew/ubuntu22.04:master"
echo ${{secrets.HOMEBREW_BREW_DOCKER_TOKEN}} |
docker login -u brewtestbot --password-stdin
docker tag brew "homebrew/ubuntu22.04:master"
docker push "homebrew/ubuntu22.04:master"
update-test:
name: ${{ matrix.name }}
runs-on: ${{ matrix.runs-on }}
Expand Down

0 comments on commit abc0584

Please sign in to comment.