Skip to content

Commit c4c541e

Browse files
committed
feat: add app slug and publish workflow
1 parent 42465b2 commit c4c541e

File tree

5 files changed

+60
-14
lines changed

5 files changed

+60
-14
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# The App ID assigned to your GitHub App.
44
APP_ID=
55
# The App name registered to your GitHub App.
6-
APP_NAME=pull
6+
APP_NAME=Pull
7+
APP_SLUG=pull
78
# The contents of the private key for your GitHub App. If you're unable to use multiline environment variables, use base64 encoding to convert the key to a single line string.
89
PRIVATE_KEY=
910
# The webhook secret used when creating a GitHub App. 'development' is used as a default, but the value in .env needs to match the value configured in your App settings on GitHub.

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Create and publish a Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
tags:
8+
- "v*"
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build-and-push-image:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Log in to the Container registry
27+
uses: docker/login-action@v3
28+
with:
29+
registry: ${{ env.REGISTRY }}
30+
username: ${{ github.actor }}
31+
password: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: Extract metadata (tags, labels) for Docker
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
38+
39+
- name: Build and push Docker image
40+
id: push
41+
uses: docker/build-push-action@v5
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
48+
- name: Generate artifact attestation
49+
uses: actions/attest-build-provenance@v1
50+
with:
51+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
52+
subject-digest: ${{ steps.push.outputs.digest }}
53+
push-to-registry: true

Dockerfile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
ARG DENO_VERSION=2.0.6
22
FROM denoland/deno:alpine-${DENO_VERSION}
33

4-
LABEL \
5-
org.opencontainers.image.title="pull" \
6-
org.opencontainers.image.description="Keep your forks up-to-date via automated PRs" \
7-
org.opencontainers.image.url="https://github.com/wei/pull" \
8-
org.opencontainers.image.documentation="https://github.com/wei/pull#readme" \
9-
org.opencontainers.image.source="https://github.com/wei/pull" \
10-
org.opencontainers.image.licenses="MIT" \
11-
org.opencontainers.image.authors="Wei He <[email protected]>" \
12-
maintainer="Wei He <[email protected]>"
13-
144
ENV \
155
####################
166
### Required ###
177
####################
188
APP_ID= \
199
APP_NAME= \
10+
APP_SLUG= \
2011
WEBHOOK_SECRET= \
2112
PRIVATE_KEY= \
2213
####################

src/configs/app-config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { readEnvOptions } from "probot/lib/bin/read-env-options.js";
33
function getAppConfig(env: Record<string, string> = Deno.env.toObject()) {
44
return {
55
...readEnvOptions(env),
6-
name: env.APP_NAME || "Pull",
7-
botName: `${(env.APP_NAME || "Pull").toLowerCase()}[bot]`,
6+
appName: env.APP_NAME || "Pull",
7+
appSlug: env.APP_SLUG || "pull",
8+
botName: `${env.APP_SLUG || "pull"}[bot]`,
89
configFilename: env.CONFIG_FILENAME || "pull.yml",
910
mongoDBUrl: env.MONGODB_URL,
1011
port: parseInt(env.PORT || "3000", 10),

src/utils/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const createLogger = (
3535
};
3636

3737
export const logger = createLogger({
38-
name: appConfig.name,
38+
name: appConfig.appName,
3939
logFormat: appConfig.logFormat,
4040
logLevel: appConfig.logLevel,
4141
logLevelInString: appConfig.logLevelInString,

0 commit comments

Comments
 (0)