-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sam Therapy <sam@samtherapy.net>
- Loading branch information
1 parent
10d17ae
commit c8aa478
Showing
9 changed files
with
119 additions
and
92 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
REGISTRY: ${{ gitea.actor != '' && 'git.froth.zone' || 'ghcr.io' }} | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: 'Deno Deploy Action' | ||
description: 'Github/Gitea/Forgejo Action for deploying applications via Deno Deploy' | ||
author: 'SamTherapy' | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
inputs: | ||
deno_deploy_token: | ||
description: 'Deno Deploy Token' | ||
required: true | ||
project: | ||
description: 'The project name used to deploy' | ||
required: true | ||
entrypoint: | ||
description: 'The entrypoint file for the deployment' | ||
required: true | ||
exclude: | ||
description: 'Files to exclude from the deployment' | ||
required: false | ||
default: '' | ||
include: | ||
description: 'Files to include in the deployment' | ||
required: false | ||
default: '' | ||
import_map: | ||
description: 'Path to the import map for the deployment' | ||
required: false | ||
default: '' | ||
production: | ||
description: 'Whether to deploy in production mode' | ||
required: false | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"imports": { | ||
"std/": "https://deno.land/std@0.220.1/" | ||
} | ||
} |
Submodule example
deleted from
c1d62a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,79 @@ | ||
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env --allow-sys --no-lock | ||
|
||
import { copy } from "https://deno.land/std@0.104.0/io/util.ts"; | ||
|
||
const env = Deno.env.toObject(); | ||
|
||
if (!env["PLUGIN_DENO_DEPLOY_TOKEN"] && !env["DENO_DEPLOY_TOKEN"]) { | ||
console.error( | ||
"A Deno Deploy token is required.\n\nGo to https://dash.deno.com/account#access-tokens to get one and set DENO_DEPLOY_TOKEN.", | ||
); | ||
Deno.exit(1); | ||
function getEnv(key: string, required = false, errorMsg?: string) { | ||
key = key.toUpperCase(); | ||
if (env[key]) return env[key]; | ||
// Drone/Woodpecker | ||
else if (env[`PLUGIN_${key}`]) return env[`PLUGIN_${key}`]; | ||
// Github Actions | ||
else if (env[`INPUT_${key}`]) return env[`INPUT_${key}`]; | ||
else if (required) { | ||
console.error(errorMsg ?? `${key} is required`); | ||
Deno.exit(1); | ||
} | ||
return ""; | ||
} | ||
|
||
if (!env["PLUGIN_ENTRYPOINT"]) { | ||
console.error("An entrypoint is required"); | ||
Deno.exit(1); | ||
} | ||
|
||
if (!env["PLUGIN_PROJECT"]) { | ||
console.error("An project is required"); | ||
Deno.exit(1); | ||
} | ||
|
||
const flags = [`-p=${env["PLUGIN_PROJECT"]}`]; | ||
Deno.env.set( | ||
"DENO_DEPLOY_TOKEN", | ||
getEnv( | ||
"DENO_DEPLOY_TOKEN", | ||
true, | ||
"A Deno Deploy token is required.\n\nGo to https://dash.deno.com/account#access-tokens to get one and set DENO_DEPLOY_TOKEN.", | ||
), | ||
); | ||
|
||
if (env["PLUGIN_DENO_DEPLOY_TOKEN"]) { | ||
flags.push(`--token=${env["PLUGIN_DENO_DEPLOY_TOKEN"]}`); | ||
} | ||
let temp: string = getEnv("Project", true, "An entrypoint is required"); | ||
const flags = [`-p=${temp}`]; | ||
|
||
if (env["PLUGIN_EXCLUDE"]) { | ||
flags.push(`--exclude=${env["PLUGIN_EXCLUDE"]}`); | ||
temp = getEnv("EXCLUDE"); | ||
if (temp) { | ||
flags.push(`--exclude=${temp}`); | ||
} | ||
|
||
if (env["PLUGIN_INCLUDE"]) { | ||
flags.push(`--include=${env["PLUGIN_INCLUDE"]}`); | ||
temp = getEnv("INCLUDE"); | ||
if (temp) { | ||
flags.push(`--include=${temp}`); | ||
} | ||
|
||
if (env["PLUGIN_IMPORT_MAP"]) { | ||
flags.push(`--import-map=${env["PLUGIN_IMPORT_MAP"]}`); | ||
temp = getEnv("IMPORT_MAP"); | ||
if (temp) { | ||
flags.push(`--import-map=${temp}`); | ||
} | ||
|
||
if (env["PLUGIN_NO_STATIC"]) { | ||
if (getEnv("NO_STATIC")) { | ||
flags.push(`--no-static`); | ||
} | ||
|
||
if (env["PLUGIN_PROD"] || env["PLUGIN_PRODUCTION"]) { | ||
if (getEnv("PRODUCTION") || getEnv("PROD")) { | ||
flags.push(`--prod`); | ||
} | ||
|
||
if (env["PLUGIN_DRY_RUN"]) { | ||
if (getEnv("DRY_RUN")) { | ||
flags.push(`--dry-run`); | ||
} | ||
|
||
console.log("Deploying to Deno Deploy......"); | ||
|
||
const prog = Deno.run({ | ||
cmd: [ | ||
"deployctl", | ||
const command = new Deno.Command("deployctl", { | ||
args: [ | ||
"deploy", | ||
...flags, | ||
env["PLUGIN_ENTRYPOINT"], | ||
getEnv("ENTRYPOINT", true, "An entrypoint is required"), | ||
], | ||
stdout: "piped", | ||
stderr: "piped", | ||
}); | ||
|
||
const process = command.spawn(); | ||
process.stdout.pipeTo(Deno.stdout.writable); | ||
process.stderr.pipeTo(Deno.stderr.writable); | ||
|
||
copy(prog.stdout, Deno.stdout); | ||
copy(prog.stderr, Deno.stderr); | ||
|
||
const status = await prog.status() | ||
|
||
prog.close(); | ||
const { success } = await process.status; | ||
|
||
if (!status.success) { | ||
if (!success) { | ||
console.error("Deno Deploy failed!"); | ||
Deno.exit(1); | ||
} |