Skip to content

Commit 441316a

Browse files
committed
feat: initial commit
0 parents  commit 441316a

File tree

9 files changed

+144
-0
lines changed

9 files changed

+144
-0
lines changed

.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# GitHub token
2+
GH_TOKEN=
3+
4+
# OpenProject token
5+
OP_TOKEN=
6+
7+
# Where OpenProject lives
8+
OP_URL=https://op.stoatinternal.com
9+
10+
# Configure a mapping of repositories to project IDs
11+
REPO_PROJECT_MAP="stoatchat/for-web:8"

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Create and publish a Docker image
2+
3+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
4+
on:
5+
push:
6+
7+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: stoatchat/openproject-zammad-sync
11+
12+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
13+
jobs:
14+
build-and-push-image:
15+
runs-on: ubuntu-latest
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
attestations: write
21+
id-token: write
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v5
26+
27+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
28+
- name: Log in to the Container registry
29+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
35+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
36+
- name: Extract metadata (tags, labels) for Docker
37+
id: meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
42+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
43+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see [Usage](https://github.com/docker/build-push-action#usage) in the README of the `docker/build-push-action` repository.
44+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
45+
- name: Build and push Docker image
46+
id: push
47+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
48+
with:
49+
context: .
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
54+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see [Using artifact attestations to establish provenance for builds](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds).
55+
- name: Generate artifact attestation
56+
uses: actions/attest-build-provenance@v3
57+
with:
58+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
59+
subject-digest: ${{ steps.push.outputs.digest }}
60+
push-to-registry: true

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"deno.enable": true,
3+
"editor.formatOnSave": true,
4+
"nixEnvSelector.nixFile": "${workspaceFolder}/default.nix",
5+
"[typescript]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
}
8+
}

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Build stage
2+
FROM denoland/deno:latest AS builder
3+
WORKDIR /app
4+
COPY . .
5+
RUN deno cache main.ts
6+
7+
# Production stage
8+
FROM denoland/deno:latest
9+
WORKDIR /app
10+
COPY --from=builder /app .
11+
CMD ["deno", "run", "--allow-read=.env", "--allow-net", "--allow-env=SECRET_TOKEN,OP_URL,OP_PROJECT,OP_TOKEN,OP_CUSTOM_FIELD,URL_PREFIX,ASSIGNEES,STATUS_MAP", "main.ts"]
12+
EXPOSE 8000

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# OpenProject-GitHub Sync
2+
3+
This is a small little service that accepts webhooks from GitHub & OpenProject to synchronise changes in both directions between specified repositories.

default.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
pkgs ? import <nixpkgs> { },
3+
}:
4+
5+
with pkgs;
6+
pkgs.mkShell {
7+
buildInputs = [
8+
deno
9+
];
10+
}

deno.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"tasks": {
3+
"start": "deno run --allow-read=.env --allow-net --allow-env=GH_TOKEN,OP_URL,OP_TOKEN,REPO_PROJECT_MAP main.ts",
4+
"watch": "deno run --watch --allow-read=.env --allow-net --allow-env=GH_TOKEN,OP_URL,OP_TOKEN,REPO_PROJECT_MAP main.ts"
5+
},
6+
"imports": {
7+
"@std/assert": "jsr:@std/assert@1",
8+
"@std/dotenv": "jsr:@std/dotenv@^0.225.5"
9+
}
10+
}

deno.lock

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO

0 commit comments

Comments
 (0)