Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/coolify-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ jobs:
- uses: actions/checkout@v4
with:
repository: ${{ job.workflow_repository || 'PracticalWorks/.github' }}
ref: ${{ job.workflow_sha || 'v1.3.0' }}
ref: ${{ job.workflow_sha || 'v1.4.0' }}
path: .pw-shared

# Self-hosted runners (Proxmox ephemeral) ship without node.
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ on:
required: false
type: string
default: ""
build-args:
description: >-
Docker build-args, one KEY=value per line, for example BUILD_SHA set
to the caller's github.sha so the image knows the commit it was
built from. Build-args are visible in image history, so never pass a
credential here.
required: false
type: string
default: ""
timeout-minutes:
required: false
type: number
Expand Down Expand Up @@ -96,6 +105,7 @@ jobs:
push: ${{ inputs.push }}
platforms: ${{ inputs.platforms }}
tags: ${{ steps.tags.outputs.tags }}
build-args: ${{ inputs.build-args }}
secrets: ${{ inputs.npmrc && format('npmrc=//npm.pkg.github.com/:_authToken={0}', github.token) || '' }}
cache-from: ${{ inputs.cache == 'inline' && format('type=registry,ref={0}:latest', inputs.image) || (inputs.cache == 'gha' && 'type=gha' || '') }}
cache-to: ${{ inputs.cache == 'inline' && 'type=inline' || (inputs.cache == 'gha' && 'type=gha,mode=max' || '') }}
4 changes: 2 additions & 2 deletions .github/workflows/pr-guard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ jobs:
- uses: actions/checkout@v4
with:
repository: ${{ job.workflow_repository || 'PracticalWorks/.github' }}
ref: ${{ job.workflow_sha || 'v1.3.0' }}
ref: ${{ job.workflow_sha || 'v1.4.0' }}
path: .pw-shared

- name: Warn when the runner gave no workflow sha
if: job.workflow_sha == ''
run: echo "::warning::job.workflow_sha is empty on this runner, so pr-guard ran the v1.3.0 script"
run: echo "::warning::job.workflow_sha is empty on this runner, so pr-guard ran the v1.4.0 script"

# Self-hosted runners (Proxmox ephemeral) ship without node.
- uses: actions/setup-node@v4
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on: [push, pull_request]

jobs:
test:
uses: PracticalWorks/.github/.github/workflows/test.yml@v1.3.0
uses: PracticalWorks/.github/.github/workflows/test.yml@v1.4.0
```

That checks out the repository, installs pnpm and Node 22, runs `pnpm install --frozen-lockfile`, then `pnpm lint` and `pnpm test`. Override any of them with `with:` (for example `test: pnpm vitest run`, or `runner: '["self-hosted"]'`). The sections below cover the other workflows and their inputs.
Expand All @@ -32,6 +32,7 @@ Always pin a tag, never `@main`. The tags so far:
| `v1.1.0` | the merge of the v1.1.0 pull request | `pr-guard.yml` sets up Node and runs its own commit's script; failures are also `::error::` annotations; `coolify-deploy.yml` waits for Coolify's real outcome and can prove a version is live |
| `v1.2.0` | the merge of the v1.2.0 pull request | `coolify-deploy.yml` takes `environment` (and `deployment`), so an Infisical identity can trust one GitHub environment of the caller; the setup action takes `cache` |
| `v1.3.0` | the merge of the v1.3.0 pull request | `coolify-deploy.yml` takes `wait` (false: post the webhook and exit, so the caller is billed seconds, not the wait) and `pre-deploy-run` (a shell step in the caller's checkout before the webhook, e.g. an env sync, instead of a separate job) |
| `v1.4.0` | the merge of the v1.4.0 pull request | `image.yml` takes `build-args`, so a Dockerfile can receive the commit sha it was built from |

A release is a new tag on a commit of `main`. Existing tags are never moved or deleted, so a caller sees a change only when it bumps its pin. Do not pin `@main`.

Expand All @@ -47,6 +48,21 @@ A release is a new tag on a commit of `main`. Existing tags are never moved or d
| `coolify-deploy.yml` | read secrets from Infisical with GitHub OIDC, POST a Coolify webhook, then wait until the deploy is proven live |
| `pr-guard.yml` | require a `## Verification` heading and a `Refs:` line; optional secret-shape scan |

`image.yml` passes `build-args` (one `KEY=value` per line) to the build. A Dockerfile that declares `ARG BUILD_SHA` and `ENV BUILD_SHA=$BUILD_SHA` then knows its own commit at runtime, for example to serve it on a version endpoint:

```yaml
jobs:
build:
permissions: { contents: read, packages: write }
uses: PracticalWorks/.github/.github/workflows/image.yml@v1.4.0
with:
image: ghcr.io/<org>/<app>
build-args: |
BUILD_SHA=${{ github.sha }}
```

Build-args are recorded in the image history, so pass a credential with `npmrc` (a build secret), never as a build-arg.

`test.yml` and `setup.yml` call `.github/actions/setup` themselves; `image.yml` installs nothing outside the Dockerfile. A following job cannot see the install from `setup.yml`.

## Caller permissions
Expand Down
10 changes: 10 additions & 0 deletions scripts/workflows.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { readFileSync } from 'node:fs';
const read = (path) => readFileSync(new URL(`../${path}`, import.meta.url), 'utf8');
const deploy = read('.github/workflows/coolify-deploy.yml');
const guard = read('.github/workflows/pr-guard.yml');
const image = read('.github/workflows/image.yml');
const setup = read('.github/actions/setup/action.yml');
const readme = read('README.md');

Expand Down Expand Up @@ -64,3 +65,12 @@ test('coolify-deploy can skip the wait and run a pre-deploy step in the caller c
const pre = deploy.indexOf('name: Pre-deploy');
assert.ok(pre > deploy.indexOf('Infisical/secrets-action') && pre > deploy.indexOf('actions/setup-node') && pre < deploy.indexOf('id: webhook'));
});

test('image takes optional build-args and hands them to the build (FACT-2010)', () => {
const block = input(image, 'build-args', 6);
assert.match(block, /required: false/);
assert.match(block, /type: string/);
assert.match(block, /default: ""/);
const build = image.slice(image.indexOf('uses: docker/build-push-action@'));
assert.match(build, /\n {10}build-args: \$\{\{ inputs\.build-args \}\}\n/);
});
Loading