Skip to content

Commit

Permalink
Manual merge branch dev, picked from commits:
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Dec 23, 2024
1 parent a495154 commit fa288b2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 97 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# syntax=docker/dockerfile:1
# IMPORTANT: Do not create big size layer due to GitHub Packages have worse performance on this!
FROM denoland/deno:bin-2.0.6 AS stage-deno
FROM denoland/deno:bin-2.1.4 AS stage-deno
FROM debian:12.8-slim
ENV APP_ROOT=/opt/hugoalh/send-discord-webhook-ghaction
ENV DEBIAN_FRONTEND=noninteractive
ENV DENO_NO_PROMPT=1
ENV DENO_NO_UPDATE_CHECK=1
COPY --from=stage-deno /deno /opt/denoland/deno/deno
RUN chmod +x /opt/denoland/deno/deno && ln -s /opt/denoland/deno/deno /usr/bin/deno
COPY _color_namespace_list.ts _fswalk.ts _payload.ts _random_integer.ts deno.jsonc mod.ts ${APP_ROOT}/
COPY _color_namespace_list.ts _payload.ts _random_integer.ts deno.jsonc mod.ts ${APP_ROOT}/
RUN deno --version && deno info && cd $APP_ROOT && deno install --lock --vendor --entrypoint mod.ts
CMD deno run --allow-env --allow-net=discord.com --allow-read --allow-write --config=$APP_ROOT/deno.jsonc --lock --vendor $APP_ROOT/mod.ts

Check warning on line 13 in Dockerfile

View workflow job for this annotation

GitHub Actions / GitHub Packages

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/

Check warning on line 13 in Dockerfile

View workflow job for this annotation

GitHub Actions / GitHub Packages

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
67 changes: 0 additions & 67 deletions _fswalk.ts

This file was deleted.

39 changes: 16 additions & 23 deletions _payload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import Color from "COLOR";
import {
walk,
type FSWalkEntry
} from "FS/walk.ts";
import {
isJSONArray,
isJSONObject,
Expand All @@ -16,10 +20,6 @@ import { globToRegExp } from "STD/path/glob-to-regexp";
import { join as pathJoin } from "STD/path/join";
import type { StringTruncator } from "STRINGOVERFLOW/mod.ts";
import { colorNamespaceList } from "./_color_namespace_list.ts";
import {
walkFS,
type FSWalkEntry
} from "./_fswalk.ts";
import { generateRandomInteger } from "./_random_integer.ts";
const thresholdContent = 2000;
const thresholdEmbeds = 10;
Expand Down Expand Up @@ -362,29 +362,22 @@ async function resolveFilesFormData(workspace: string, files: string[]): Promise
}
export async function resolveFiles(files: string[], glob: boolean): Promise<FormData | undefined> {
const workspace: string = getRunnerWorkspacePath();
const workspaceStat: Deno.FileInfo = await Deno.stat(workspace);
if (!workspaceStat.isDirectory) {
const workspaceStatL: Deno.FileInfo = await Deno.lstat(workspace);
if (!workspaceStatL.isDirectory) {
throw new Deno.errors.NotADirectory(`Workspace \`${workspace}\` is not a directory!`);
}
if (files.length === 0) {
return undefined;
}
if (glob) {
const matchers: RegExp[] = files.map((file: string): RegExp => {
return globToRegExp(file, { caseInsensitive: true });
});
const filesFmt: string[] = (await Array.fromAsync(walkFS(workspace, {
includeDirs: false,
includeRoot: false,
includeSymlinks: false
}))).filter(({
pathAbsolute,
pathRelative
}: FSWalkEntry): boolean => {
return pathAbsolute.startsWith(workspace) && matchers.some((matcher: RegExp): boolean => {
return matcher.test(pathRelative);
});
}).map(({ pathRelative }: FSWalkEntry): string => {
const filesFmt: string[] = await Array.fromAsync(await walk(workspace, {
includeDirectories: false,
includeSymlinkDirectories: false,
includeSymlinkFiles: false,
matches: files.map((file: string): RegExp => {
return globToRegExp(file, { caseInsensitive: true });
})
}), ({ pathRelative }: FSWalkEntry): string => {
return pathRelative;
});
if (filesFmt.length === 0) {
Expand All @@ -396,8 +389,8 @@ export async function resolveFiles(files: string[], glob: boolean): Promise<Form
if (pathIsAbsolute(file)) {
throw new Error(`\`${file}\` is not a relative file path!`);
}
const fileStat: Deno.FileInfo = await Deno.stat(pathJoin(workspace, file));
if (!fileStat.isFile) {
const fileStatL: Deno.FileInfo = await Deno.lstat(pathJoin(workspace, file));
if (!fileStatL.isFile) {
throw new Error(`\`${file}\` is not a file!`);
}
}))).map((fileStat: PromiseSettledResult<void>): unknown => {
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ outputs:
description: "{string} Request status text."
runs:
using: "docker"
image: "docker://ghcr.io/hugoalh/send-discord-webhook-ghaction:7.0.3"
image: "docker://ghcr.io/hugoalh/send-discord-webhook-ghaction:7.0.4"
branding:
icon: "send"
color: "blue"
6 changes: 3 additions & 3 deletions deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"COLOR": "https://esm.sh/color@4.2.3",
"COLORNAMESPACELISTCOMMUNITY": "https://esm.sh/color-name-list@10.28.0/dist/colornames.esm.js",
"EXFETCH/": "https://raw.githubusercontent.com/hugoalh/exfetch-es/v0.5.1/",
"FS/": "https://raw.githubusercontent.com/hugoalh/fs-es/v0.2.0/",
"GHACTIONS/": "https://raw.githubusercontent.com/hugoalh/github-actions-core-es/v0.4.2/",
"ISJSON/": "https://raw.githubusercontent.com/hugoalh/is-json-es/v1.0.4/",
"REGEXPURL": "https://esm.sh/url-regex-safe@4.0.0",
"STD/assert": "jsr:@std/assert@1.0.7",
"STD/fs": "jsr:@std/fs@1.0.5",
"STD/media-types": "jsr:@std/media-types@1.0.3",
"STD/assert": "jsr:@std/assert@1.0.8",
"STD/media-types": "jsr:@std/media-types@1.1.0",
"STD/path": "jsr:@std/path@1.0.8",
"STD/yaml": "jsr:@std/yaml@1.0.5",
"STRINGOVERFLOW/": "https://raw.githubusercontent.com/hugoalh/string-overflow-es/v2.0.4/"
Expand Down
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from "./_payload.ts";
console.log("Initialize.");
const exfetch: ExFetch = new ExFetch({
userAgent: `${userAgentDefault} SendDiscordWebhook.GitHubAction/7.0.3`
userAgent: `${userAgentDefault} SendDiscordWebhook.GitHubAction/7.0.4`
});
const splitterNewLine = /\r?\n/g;
const splitterCommonDelimiter = /,|\r?\n/g;
Expand Down

0 comments on commit fa288b2

Please sign in to comment.