Compare commits

...

2 Commits

Author SHA1 Message Date
platane
df3c0e5fd8 📓 add readme 2020-07-20 10:19:52 +02:00
platane
8a06b668cd 🚀 fix action 2020-07-20 10:18:24 +02:00
10 changed files with 67 additions and 29 deletions

View File

@@ -6,22 +6,22 @@ on:
- master
jobs:
test:
deploy-demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v1.4.2
with:
node-version: 14
- uses: bahmutov/npm-install@v1
- uses: bahmutov/npm-install@v1.4.1
- run: yarn build:demo
env:
BASE_PATHNAME: "snk"
- uses: crazy-max/ghaction-github-pages@068e494
- uses: crazy-max/ghaction-github-pages@v2.1.1
with:
target_branch: gh-pages
build_dir: packages/demo/dist

View File

@@ -9,12 +9,38 @@ jobs:
steps:
- run: sudo apt-get install gifsicle graphicsmagick
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v1.4.2
with:
node-version: 14
- uses: bahmutov/npm-install@v1
- uses: bahmutov/npm-install@v1.4.1
- run: yarn type
- run: yarn lint
- run: yarn test --ci
- run: yarn build:action
test-action:
runs-on: ubuntu-latest
steps:
- run: mkdir dist
- name: generate-snake-game-from-github-contribution-grid
id: snake-gif
uses: Platane/snk@master
with:
github_user_name: platane
gif_out_path: dist/github-contribution-grid-snake.gif
- name: ensure the generated file exists
run: |
ls -l ${{ steps.snake-gif.outputs.gif_out_path }}
test -f ${{ steps.snake-gif.outputs.gif_out_path }}
- uses: crazy-max/ghaction-github-pages@v2.1.1
with:
target_branch: output
build_dir: dist
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN_GH_PAGES }}

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@ node_modules
npm-debug.log*
yarn-error.log*
dist
build
build
out.gif

View File

@@ -4,7 +4,16 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends gifsicle graphicsmagick \
&& rm -rf /var/lib/apt/lists/*
COPY packages/action/dist/* ./github-contribution-grid-snake
COPY tsconfig.json package.json yarn.lock /github/snk/
COPY packages /github/snk/packages
CMD ["node", "github-contribution-grid-snake/index.js"]
RUN ( \
cd /github/snk \
&& find . \
&& yarn install --frozen-lockfile \
&& yarn build:action \
&& mv packages/action/dist/* . \
&& rm -rf packages tsconfig.json package.json yarn.lock node_modules \
)
CMD ["node", "/github/snk/index.js"]

9
README.md Normal file
View File

@@ -0,0 +1,9 @@
# snk
![](https://raw.githubusercontent.com/Platane/snk/output/github-contribution-grid-snake.gif)
Generates a snake game from a github user contributions grid and output a screen capture as gif
---
[demo](platane.github.io/snk/index.html)

View File

@@ -1,23 +1,20 @@
name: "github-contribution-grid-snake"
description: ""
name: "generate-snake-game-from-github-contribution-grid"
description: "Generates a snake game from a github user contributions grid and output a screen capture as gif"
author: "platane"
outputs:
gif_out_path:
description: ""
description: "path of the generated gif"
runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.github_user_name }}
- ${{ inputs.gif_out_path }}
inputs:
github_user_name:
description: ""
description: "github user name"
required: true
gif_out_path:
description: ""
description: "path of the generated gif"
required: false
default: "./github-contribution-grid-snake.gif"

View File

@@ -1,5 +1,6 @@
{
"name": "snk",
"description": "Generates a snake game from a github user contributions grid and output a screen capture as gif",
"version": "1.0.0",
"private": true,
"repository": "github:platane/snk",

View File

@@ -1,3 +0,0 @@
!dist
!dist/build
out.gif

View File

@@ -4,15 +4,14 @@ import { generateContributionSnake } from "./generateContributionSnake";
(async () => {
try {
console.log(core.getInput("user_name"));
console.log(core.getInput("gif_out_path"));
console.log("--");
console.log(process.cwd());
console.log("--");
console.log(fs.readdirSync(process.cwd()));
const userName = core.getInput("github_user_name");
const gifOutPath = core.getInput("gif_out_path");
const buffer = await generateContributionSnake(core.getInput("user_name"));
fs.writeFileSync(core.getInput("gif_out_path"), buffer);
const buffer = await generateContributionSnake(userName);
fs.writeFileSync(gifOutPath, buffer);
console.log(`::set-output name=gif_out_path::${gifOutPath}`);
} catch (e) {
core.setFailed(`Action failed with "${e.message}"`);
}

View File

@@ -1 +0,0 @@
out.gif