Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow/tests: move Docker tests to docker.yml #18168

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved
release:
types:
- published
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

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: |
echo "$TOKEN" | docker login ghcr.io -u BrewTestBot --password-stdin
ZhongRuoyu marked this conversation as resolved.
Show resolved Hide resolved
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: |
echo "$TOKEN" | docker login -u brewtestbot --password-stdin
ZhongRuoyu marked this conversation as resolved.
Show resolved Hide resolved
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