├── .github └── main.workflow ├── Dockerfile ├── README.md ├── entrypoint.sh └── package.json /.github/main.workflow: -------------------------------------------------------------------------------- 1 | workflow "Test" { 2 | on = "push" 3 | resolves = ["actions/bin/sh"] 4 | } 5 | 6 | action "Create File" { 7 | uses = "./" 8 | env = { 9 | FILE_NAME = "test_file" 10 | FILE_DATA = "hello\nthis\nis\na\ntest" 11 | } 12 | } 13 | 14 | action "actions/bin/sh" { 15 | uses = "actions/bin/sh@master" 16 | needs = ["Create File"] 17 | args = ["cat test_file"] 18 | } 19 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stable-slim 2 | 3 | # Labels for GitHub to read your action 4 | LABEL "com.github.actions.name"="Create File" 5 | LABEL "com.github.actions.description"="Creates a file from environment variables" 6 | # Here all of the available icons: https://feathericons.com/ 7 | LABEL "com.github.actions.icon"="file-plus" 8 | # And all of the available colors: https://developer.github.com/actions/creating-github-actions/creating-a-docker-container/#label 9 | LABEL "com.github.actions.color"="green" 10 | 11 | COPY entrypoint.sh /entrypoint.sh 12 | 13 | ENTRYPOINT ["/entrypoint.sh"] 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # create-file-action 2 | Github Action to create a new file from environment config 3 | 4 | ## Usage with String `FILE_DATA` 5 | 6 | ```workflow 7 | - uses: "finnp/create-file-action@master" 8 | env: 9 | FILE_NAME: "dir/fileName.txt" 10 | FILE_DATA: "file content" 11 | ``` 12 | 13 | ## Usage with base64 `FILE_BASE64` 14 | 15 | ```workflow 16 | - uses: "finnp/create-file-action@master" 17 | env: 18 | FILE_NAME: "dir/fileName.txt" 19 | FILE_BASE64: "ZWFzdGVyZWdnLWxvbAo=" 20 | ``` 21 | 22 | Create your file with `cat filename | base64` 23 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ "$(dirname "$FILE_NAME")" != "." ] 4 | then 5 | mkdir -p "$(dirname "$FILE_NAME")" 6 | fi 7 | if [[ -z "${FILE_BASE64}" ]]; then 8 | echo "Using FILE_DATA to write to $FILE_NAME" 9 | echo $FILE_DATA > "$FILE_NAME" 10 | else 11 | echo "Using FILE_BASE64 to write to $FILE_NAME" 12 | echo $FILE_BASE64 | base64 --decode > $FILE_NAME 13 | fi 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "create-file-action", 3 | "version": "1.0.0", 4 | "description": "Create a file", 5 | "main": "entrypoint.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "Finn Pauls", 11 | "license": "ISC" 12 | } 13 | --------------------------------------------------------------------------------