-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
195 additions
and
78 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,70 +1,13 @@ | ||
# 🥔 Special Octo Potato | ||
|
||
This is my blasting field for Github Actions. The place to test workflows, actions their result. | ||
|
||
## Notes | ||
|
||
* Official help for [GitHub Actions](https://help.github.com/en/actions) | ||
* You cannot use the `alpine` image as `runs-on` | ||
* The only available options can be found on the page: [Virtual Environments for GitHub-hosted Runners](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners) | ||
* You can use a Docker image | ||
* Job names must start with a letter or `_` and contain only alphanumeric characters, `-`, or `_` | ||
* You can react to tags without declaring the branch | ||
* If you have a syntax error in your workflow file, you lose access to the history of previous builds for that workflow | ||
* The workflow must contain at least one job with no dependencies | ||
* If the cron schedule contains a slash `/` character, it needs to be in quotes | ||
* Scheduled tasks seem to have some delay in starting | ||
* The difference between `github.ref_name` and `GITHUB_REF` while dealing with tag: one return only the tag name, the other the full tag name (with prefix) | ||
|
||
### Github NPM Packages | ||
|
||
There is possibility for publish npm packages directly on Github (as not scoped repository). See [GitHub Packages: Your packages, at home with their code](https://npm.pkg.github.com). | ||
|
||
The usage in workflow is described here: [Publishing Node.js packages](https://docs.github.com/en/actions/guides/publishing-nodejs-packages). | ||
|
||
Example set-up code: | ||
|
||
```yml | ||
- name: "Set up the NPM" | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
registry-url: 'https://npm.pkg.github.com' | ||
scope: '@dplocki' | ||
``` | ||
Later usage: | ||
```yml | ||
- name: "Compering version" | ||
run: | | ||
echo `npm info @dplocki/generic-conversation-bot version` | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
``` | ||
### Create tag | ||
```yml | ||
- name: Create Tag | ||
uses: negz/create-tag@v1 | ||
with: | ||
version: v0.1.1 | ||
message: Release for version v0.1.1 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
## Multiline scripts in YML | ||
```yml | ||
run: | | ||
cat << EOF > run.py | ||
echo line 1 | ||
echo line 2 | ||
; no indents on each of this lines | ||
EOF | ||
``` | ||
## Links | ||
* [GitHub Actions to securely publish npm packages](https://snyk.io/blog/github-actions-to-securely-publish-npm-packages/) | ||
# 📚🐙 Bookmarklets library | ||
|
||
The repository for keeping bookmarklets. | ||
|
||
Unfortunetly on Github's markdown you cannot simply add comfortable links, so you have to drag and drop (on the bookmarks' bar) the code by yourself. | ||
|
||
## Bookmarklets | ||
|
||
### Explain XKCD | ||
|
||
``` | ||
javascript:(function()%7Bconst%20url%20%3D%20window.location.href%3B%0A%20%20%20%20const%20regex%20%3D%20%2Fhttps%3A%5C%2F%5C%2Fxkcd%5C.com%5C%2F(%5Cd%2B)%5C%2F%2F%3B%0A%20%20%20%20const%20match%20%3D%20url.match(regex)%3B%0A%0A%20%20%20%20if%20(match)%20%7B%0A%20%20%20%20%20%20%20%20window.location.href%20%3D%20%60https%3A%2F%2Fwww.explainxkcd.com%2Fwiki%2Findex.php%2F%24%7Bmatch%5B1%5D%7D%60%3B%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20alert('That%20is%20not%20a%20XKCD%20page')%3B%0A%20%20%20%20%7D%7D)()%3B | ||
``` |
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,14 @@ | ||
/* | ||
### Explain XKCD | ||
If you are on [xkcd](https://xkcd.com), it will redirect you on the proper subpage on the [explain xkcd wiki](https://www.explainxkcd.com/). Otherwise display the alert. | ||
*/ | ||
const url = window.location.href; | ||
const regex = /https:\/\/xkcd\.com\/(\d+)\//; | ||
const match = url.match(regex); | ||
|
||
if (match) { | ||
window.location.href = `https://www.explainxkcd.com/wiki/index.php/${match[1]}`; | ||
} else { | ||
alert('That is not a XKCD page'); | ||
} |
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,50 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const uglifyJS = require("uglify-js"); | ||
|
||
function* loadPartOfFile(startToken, endToken, fileName) { | ||
const lines = fs.readFileSync(fileName, 'utf8').split('\n'); | ||
|
||
let isBlock = !startToken; | ||
for (const line of lines) { | ||
if (!isBlock && line === startToken) { | ||
isBlock = true; | ||
continue; | ||
} | ||
|
||
if (isBlock && line === endToken) { | ||
isBlock = false; | ||
return; | ||
} | ||
|
||
if (isBlock) { | ||
yield line; | ||
} | ||
} | ||
} | ||
|
||
function bookmarklet(bookmarkletFilePath) { | ||
return 'javascript:' + encodeURIComponent('(function(){' + uglifyJS.minify(fs.readFileSync(bookmarkletFilePath, "utf8")).code + '})()'); | ||
} | ||
|
||
const README_START_MARKER = '## Bookmarklets'; | ||
const bookmarkletsDirectory = '../bookmarklets'; | ||
|
||
let result = [...loadPartOfFile(null, README_START_MARKER, '../README.md'), README_START_MARKER, '']; | ||
|
||
for (const fileName of fs.readdirSync(bookmarkletsDirectory)) { | ||
const bookmarkletFilePath = path.join(bookmarkletsDirectory, fileName); | ||
|
||
result = result.concat([ | ||
...loadPartOfFile('/*', '*/', bookmarkletFilePath), | ||
'', | ||
'```bookmarklet', | ||
bookmarklet(bookmarkletFilePath), | ||
'```', | ||
'' | ||
]); | ||
} | ||
|
||
for (const line of result) { | ||
console.log(line); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,5 @@ | ||
{ | ||
"dependencies": { | ||
"uglify-js": "^3.18.0" | ||
} | ||
} |
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,70 @@ | ||
# 🥔 Special Octo Potato | ||
|
||
This is my blasting field for Github Actions. The place to test workflows, actions their result. | ||
|
||
## Notes | ||
|
||
* Official help for [GitHub Actions](https://help.github.com/en/actions) | ||
* You cannot use the `alpine` image as `runs-on` | ||
* The only available options can be found on the page: [Virtual Environments for GitHub-hosted Runners](https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners) | ||
* You can use a Docker image | ||
* Job names must start with a letter or `_` and contain only alphanumeric characters, `-`, or `_` | ||
* You can react to tags without declaring the branch | ||
* If you have a syntax error in your workflow file, you lose access to the history of previous builds for that workflow | ||
* The workflow must contain at least one job with no dependencies | ||
* If the cron schedule contains a slash `/` character, it needs to be in quotes | ||
* Scheduled tasks seem to have some delay in starting | ||
* The difference between `github.ref_name` and `GITHUB_REF` while dealing with tag: one return only the tag name, the other the full tag name (with prefix) | ||
|
||
### Github NPM Packages | ||
|
||
There is possibility for publish npm packages directly on Github (as not scoped repository). See [GitHub Packages: Your packages, at home with their code](https://npm.pkg.github.com). | ||
|
||
The usage in workflow is described here: [Publishing Node.js packages](https://docs.github.com/en/actions/guides/publishing-nodejs-packages). | ||
|
||
Example set-up code: | ||
|
||
```yml | ||
- name: "Set up the NPM" | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16' | ||
registry-url: 'https://npm.pkg.github.com' | ||
scope: '@dplocki' | ||
``` | ||
Later usage: | ||
```yml | ||
- name: "Compering version" | ||
run: | | ||
echo `npm info @dplocki/generic-conversation-bot version` | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
``` | ||
### Create tag | ||
```yml | ||
- name: Create Tag | ||
uses: negz/create-tag@v1 | ||
with: | ||
version: v0.1.1 | ||
message: Release for version v0.1.1 | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
``` | ||
## Multiline scripts in YML | ||
```yml | ||
run: | | ||
cat << EOF > run.py | ||
echo line 1 | ||
echo line 2 | ||
; no indents on each of this lines | ||
EOF | ||
``` | ||
## Links | ||
* [GitHub Actions to securely publish npm packages](https://snyk.io/blog/github-actions-to-securely-publish-npm-packages/) |