Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
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
71 changes: 71 additions & 0 deletions .github/workflows/mu-plugins-wpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build MU Plugins

on:
push:
branches:
- master
paths:
- "mu-plugins-wpc/**"
- ".github/workflows/mu-plugins-wpc.yml"
pull_request:
paths:
- "mu-plugins-wpc/**"
- ".github/workflows/mu-plugins-wpc.yml"
workflow_dispatch:
repository_dispatch:
types:
- build-mu-plugins-wpc

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the source code
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-docker-action@b60f85385d03ac8acfca6d9996982511d8620a19 # v4.3.0
with:
daemon-config: |
{
"features": {
"containerd-snapshotter": true
}
}

- name: Login to DockerHub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
with:
registry: https://ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.event_name != 'pull_request' }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3

- name: Build and push
uses: docker/bake-action@37816e747588cb137173af99ab33873600c46ea8 # v6.8.0
with:
source: .
workdir: mu-plugins-wpc
files: docker-bake.hcl
push: ${{ github.event_name != 'pull_request' }}
no-cache: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' || github.event_name == 'repository_dispatch' }}
set: |
*.output=type=docker,rewrite-timestamp=true
*.output=type=image,push=${{ github.base_ref == null }},rewrite-timestamp=true
env:
SOURCE_DATE_EPOCH: 0
GITHUB_TOKEN: ${{ github.token }}
Copy link

Copilot AI Aug 1, 2025

Choose a reason for hiding this comment

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

The GitHub context variable should be github.token with lowercase 't', not GITHUB_TOKEN. This should be ${{ github.token }}.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

What?

2 changes: 2 additions & 0 deletions mu-plugins-wpc/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!run.sh
18 changes: 18 additions & 0 deletions mu-plugins-wpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# syntax=docker/dockerfile:1.7
FROM scratch AS build
ARG BRANCH
ARG GITHUB_TOKEN
ADD https://x:${GITHUB_TOKEN}@github.com/Automattic/vip-go-mu-plugins-wpcloud.git#${BRANCH} .

FROM ghcr.io/automattic/vip-container-images/helpers:v1@sha256:6e27a9d364109f195cc518a3f58add74ffd51c574d5b1fa7acbbb19410e08e43 AS helpers
FROM busybox:stable-musl@sha256:74322b4716a11835c6f413fe9ffc2608ffdb8452f51cad9514a2b804908dc16e AS busybox
RUN mkdir /shared

FROM scratch
COPY --from=helpers /rsync /usr/bin/rsync
COPY --from=busybox /bin/busybox /bin/
COPY --from=build --link /wordpress/mu-plugins /mu-plugins
COPY run.sh /run.sh
RUN ["/bin/busybox", "--install", "-s"]

VOLUME ["/shared"]
56 changes: 56 additions & 0 deletions mu-plugins-wpc/docker-bake.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
variable "GITHUB_TOKEN" {
default = ""
}

target "base" {
dockerfile = "Dockerfile"
platforms = ["linux/amd64", "linux/arm64"]
pull = true
output = [
"type=image"
]

cache-from = [
"type=gha,scope=mu-plugins-wpc"
]

cache-to = [
"type=gha,mode=max,scope=mu-plugins-wpc"
]

args = {
GITHUB_TOKEN = "${GITHUB_TOKEN}"
}
}

target "develop" {
inherits = ["base"]
tags = ["ghcr.io/automattic/vip-container-images/mu-plugins-wpc:develop"]
args = {
BRANCH = "develop-built"
}
}

target "staging" {
inherits = ["base"]
tags = ["ghcr.io/automattic/vip-container-images/mu-plugins-wpc:staging"]
args = {
BRANCH = "staging-built"
}
}

target "production" {
inherits = ["base"]
tags = ["ghcr.io/automattic/vip-container-images/mu-plugins-wpc:production"]
args = {
BRANCH = "production-built"
}
}

group "default" {
targets = [
"develop",
"staging",
"production"
]
}
7 changes: 7 additions & 0 deletions mu-plugins-wpc/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

if [ ! -f /shared/.version ] || ! cmp -s /shared/.version /mu-plugins/.version; then
rm -f /shared/.version
rsync -ac --delete-after --exclude='/.version' /mu-plugins/ /shared/
cp /mu-plugins/.version /shared/
fi
Loading