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

Create test-ubuntu-git Docker Container for Proxy Tests #1616

Merged
merged 6 commits into from Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/update-test-ubuntu-git.yml
@@ -0,0 +1,55 @@
name: Publishes the test-ubuntu-git Container Image

on:
# Use an on demand workflow trigger.
# (Forked copies of actions/checkout won't have permission to update GHCR.io/actions,
# so avoid trigger events that run automatically.)
workflow_dispatch:
inputs:
pushToContainerRegistry:
type: boolean
required: true
default: false

env:
REGISTRY: ghcr.io
IMAGE_NAME: actions/test-ubuntu-git

jobs:
build-and-push-image:
runs-on: ubuntu-latest
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Use `docker/login-action` to log in to GHCR.io.
# Once published, the packages are scoped to the account defined here.
- name: Log in to the ghcr.io container registry
uses: docker/login-action@v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is ${{ github.actor }} always the actions org?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's whomever triggers the workflow, (I can devise a quick test to confirm), but I believe it'll still work as desired. All the examples use ${{ github.actor }}.

The explanation is a bit murky, but some documentation is here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.repository_owner is another option, but I wanted to try it this way first and see if it works OK.

I figure it should help make auth-related failures in the workflow more clear. (e.g. joe triggered the workflow, but joe doesn't have the requisite permissions).

It might also be handy to see who published the image in GHCR.io in the event we need to do some forensics.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see other workflows in the actions org that also use github.actor when pushing to ghcr.io including actions/runner.

password: ${{ secrets.GITHUB_TOKEN }}

# Use `docker/metadata-action` to preserve tags and labels that exist on the GHCR.io container image.
# - name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v5.5.1
# with:
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
Comment on lines +40 to +45
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this block is necessary at this point. I'd like to see what happens without it first.


# Use `docker/build-push-action` to build (and optionally publish) the image.
- name: Build and push Docker image
uses: docker/build-push-action@v5.1.0
with:
context: .
file: images/test-ubuntu-git.Dockerfile
push: ${{ inputs.pushToContainerRegistry }}
tags: ${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
10 changes: 10 additions & 0 deletions images/test-ubuntu-git.Dockerfile
@@ -0,0 +1,10 @@
# Defines the test-ubuntu-git Container Image.
# Consumed by actions/checkout CI/CD validation workflows.

FROM ubuntu:latest

RUN apt update
RUN apt install -y git

LABEL org.opencontainers.image.description="Ubuntu image with git pre-installed"
LABEL org.opencontainers.image.licenses=MIT