Skip to content

Commit

Permalink
Merge branch 'master' into releases/v1
Browse files Browse the repository at this point in the history
  • Loading branch information
sarisia committed Apr 17, 2022
2 parents bf7d621 + 80c8c1b commit b81fcab
Show file tree
Hide file tree
Showing 10 changed files with 7,296 additions and 98 deletions.
7 changes: 5 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
ARG VARIANT="14-buster"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

COPY library-scripts/fish-debian.sh /tmp/library-scripts/
RUN apt-get update && bash /tmp/library-scripts/fish-debian.sh

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment if you want to install an additional version of node using nvm
ARG EXTRA_NODE_VERSION=12.13
RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# ARG EXTRA_NODE_VERSION=12.13
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"

# [Optional] Uncomment if you want to install more global node modules
# RUN sudo -u node npm install -g npm-check-updates
5 changes: 2 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick a Node version: 10, 12, 14
"args": { "VARIANT": "14" }
"args": { "VARIANT": "16-bullseye" }
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Add the IDs of extensions you want installed when the container is created.
Expand All @@ -28,6 +27,6 @@
"remoteUser": "node",

"features": {
"fish": "latest"
// "fish": "latest"
}
}
96 changes: 96 additions & 0 deletions .devcontainer/library-scripts/fish-debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
#
# ** This script is community supported **
# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/fish.md
# Maintainer: @andreiborisov
#
# Syntax: ./fish-debian.sh [whether to install Fisher] [non-root user]

INSTALL_FISHER=${1:-"true"}
USERNAME=${2:-"automatic"}

set -e

if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi

export DEBIAN_FRONTEND=noninteractive

# Determine the appropriate non-root user
if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
USERNAME=""
POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
if id -u ${CURRENT_USER} > /dev/null 2>&1; then
USERNAME=${CURRENT_USER}
break
fi
done
if [ "${USERNAME}" = "" ]; then
USERNAME=root
fi
elif [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi

# Function to run apt-get if needed
apt_get_update_if_needed()
{
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update
else
echo "Skipping apt-get update."
fi
}

# Checks if packages are installed and installs them if not
check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update_if_needed
apt-get -y install --no-install-recommends "$@"
fi
}

check_packages curl ca-certificates gnupg2 apt-transport-https

# Install fish shell
echo "Installing fish shell..."
if grep -q 'Ubuntu' < /etc/os-release; then
apt-get -y install --no-install-recommends software-properties-common
apt-add-repository -y ppa:fish-shell/release-3
apt-get update
apt-get -y install --no-install-recommends fish
apt-get autoremove -y
elif grep -q 'Debian' < /etc/os-release; then
if grep -q 'stretch' < /etc/os-release; then
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_9.0/ /' | tee /etc/apt/sources.list.d/shells:fish.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_9.0/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null
elif grep -q 'buster' < /etc/os-release; then
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_10/ /' | tee /etc/apt/sources.list.d/shells:fish.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null
elif grep -q 'bullseye' < /etc/os-release; then
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_11/ /' | tee /etc/apt/sources.list.d/shells:fish.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:3/Debian_11/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null
fi
apt update
apt install -y fish
apt autoremove -y
fi

# Install Fisher
if [ "${INSTALL_FISHER}" = "true" ]; then
echo "Installing Fisher..."
fish -c 'curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher'
if [ "${USERNAME}" != "root" ]; then
sudo -u $USERNAME fish -c 'curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher'
fi
fi

echo "Done!"
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Discord Notification Made Easy.

![image](https://user-images.githubusercontent.com/33576079/102154007-d6e3ec80-3ebb-11eb-9389-f372954813c5.png)

- :sushi: **_Zero-configure!_** Works perfectly out of the box.
- :sushi: **_Universal!_** Supports Linux (Ubuntu), macOS and Windows.
- :sushi: **_Faster startup!_** Faster than ones written in Docker container action.
- :sushi: **_Zero-configuration!_** Works perfectly out of the box.
- :sushi: **_Universal!_** Supports Linux (Ubuntu), macOS and Windows runners.
- :sushi: **_Fast startup!_** Faster than ones written as Docker container action.

---

Expand All @@ -18,8 +18,8 @@ Discord Notification Made Easy.
- [FAQ](#faq)
- [Questions? Bugs?](#questions-bugs)

> :warning: If you're reading this document in Marketplace page,
> please refer to the [latest document here](https://github.com/sarisia/actions-status-discord).
> :warning: If you're reading this document in master branch,
> please refer to the [latest released document here](https://github.com/marketplace/actions/actions-status-discord).
<!-- * [Migrate to v2](#migrate-to-v2) -->

Expand Down Expand Up @@ -81,6 +81,8 @@ For `if` parameter, see

### Inputs

#### General customizations

| Key | Required | Value | Default | Description |
| - | - | - | - | - |
| webhook | No | String | `env.DISCORD_WEBHOOK` | Discord webhook endpoind like:<br>`https://discordapp.com/api/webhooks/...`<br>This overrides `env.DISCORD_WEBHOOK`.<br>**DO NOT APPEND [`/github` SUFFIX](https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook)!** |
Expand All @@ -89,12 +91,20 @@ For `if` parameter, see
| description | No | String | | Description included in message |
| image | No | String | | Image attached to the message |
| color | No | Hex string like: `0xFFFFFF` | | Overrides Discord embed color |
| url | No | String | | URL to jump when the title is clicked |
| username | No | String | | Overrides Discord webhook username |
| avatar_url | No | String | | Overrides Discord webhook avatar url |

#### Advanced usages

| Key | Required | Value | Default | Description |
| - | - | - | - | - |
| nofail | No | `true` or `false` | `true` | This action won't make workflow failed by default. If set to `false`, this action will set status failed when failed to notify. |
| nocontext | No | `true` or `false` | `false` | Set `true` to suppress GitHub context fields (`Repository`, `Ref`, etc). |
| noprefix | No | `true` or `false` | `false` | Set `true` to avoid appending job status (`Success: `, etc.) to title |
| nodetail | No | `true` or `false` | `false` | Set `true` will set both `nocontext` and `noprefix` to `true` |
| notimestamp | No | `true` or `false` | `false` | Set `true` to avoid appending timestamp |


<details>
<summary>Show deprecated</summary>
Expand Down
10 changes: 9 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ inputs:
color:
description: "Overrides Discord embed color"
required: false
url:
description: "URL to jump when the title is clicked"
required: false
username:
description: "Overrides Discord webhook username"
required: false
Expand All @@ -48,9 +51,14 @@ inputs:
description: "Suppress detailed embed fields"
required: false
default: 'false'
notimestamp:
description: "Avoid appending timestamp"
required: false
default: 'false'


runs:
using: 'node12'
using: 'node16'
main: 'lib/main.js'

branding:
Expand Down
Loading

0 comments on commit b81fcab

Please sign in to comment.