├── .gitattributes ├── .github ├── dependabot.yml ├── linters │ ├── .checkov.yaml │ ├── .markdown-lint.yml │ └── .yaml-lint.yml └── workflows │ ├── ci.yml │ └── linter.yml ├── .gitignore ├── .prettierrc.json ├── CODEOWNERS ├── Dockerfile ├── LICENSE ├── README.md ├── action.yml └── entrypoint.sh /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: docker 4 | directory: / 5 | schedule: 6 | interval: weekly 7 | groups: 8 | docker-minor: 9 | update-types: 10 | - minor 11 | - patch 12 | 13 | - package-ecosystem: github-actions 14 | directory: / 15 | schedule: 16 | interval: weekly 17 | groups: 18 | actions-minor: 19 | update-types: 20 | - minor 21 | - patch 22 | -------------------------------------------------------------------------------- /.github/linters/.checkov.yaml: -------------------------------------------------------------------------------- 1 | quiet: true 2 | skip-check: 3 | # Ensure that HEALTHCHECK instructions have been added to container images 4 | - CKV_DOCKER_2 5 | # Ensure that a user for the container has been created 6 | - CKV_DOCKER_3 7 | -------------------------------------------------------------------------------- /.github/linters/.markdown-lint.yml: -------------------------------------------------------------------------------- 1 | # Unordered list style 2 | MD004: 3 | style: dash 4 | 5 | # Ordered list item prefix 6 | MD029: 7 | style: one 8 | -------------------------------------------------------------------------------- /.github/linters/.yaml-lint.yml: -------------------------------------------------------------------------------- 1 | rules: 2 | document-end: disable 3 | document-start: 4 | level: warning 5 | present: false 6 | line-length: 7 | level: warning 8 | max: 80 9 | allow-non-breakable-words: true 10 | allow-non-breakable-inline-mappings: true 11 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Continuous Integration 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | permissions: 12 | contents: read 13 | 14 | jobs: 15 | test-docker: 16 | name: Docker Tests 17 | runs-on: ubuntu-latest 18 | 19 | # Run a local registry to push to 20 | services: 21 | registry: 22 | image: registry:2 23 | ports: 24 | - 5001:5000 25 | 26 | env: 27 | TEST_TAG: localhost:5001/actions/hello-world-docer-action:latest 28 | 29 | steps: 30 | - name: Checkout 31 | id: checkout 32 | uses: actions/checkout@v4 33 | 34 | - name: Setup Docker BuildX 35 | id: setup-buildx 36 | uses: docker/setup-buildx-action@v3 37 | with: 38 | install: true 39 | driver-opts: network=host 40 | 41 | - name: Build the Container 42 | id: build 43 | uses: docker/build-push-action@v6 44 | with: 45 | context: . 46 | push: true 47 | tags: ${{ env.TEST_TAG }} 48 | 49 | - name: Run the Container 50 | id: run 51 | env: 52 | INPUT_WHO_TO_GREET: Mona Lisa Octocat 53 | run: | 54 | docker run \ 55 | --env INPUT_WHO_TO_GREET="${{ env.INPUT_WHO_TO_GREET }}" \ 56 | --rm ${{ env.TEST_TAG }} 57 | 58 | test-action: 59 | name: GitHub Actions Test 60 | runs-on: ubuntu-latest 61 | 62 | steps: 63 | - name: Checkout 64 | id: checkout 65 | uses: actions/checkout@v4 66 | 67 | - name: Test Local Action 68 | id: test-action 69 | uses: ./ 70 | with: 71 | who-to-greet: Mona Lisa Octocat 72 | 73 | - name: Print Output 74 | id: output 75 | run: echo "${{ steps.test-action.outputs.time }}" 76 | -------------------------------------------------------------------------------- /.github/workflows/linter.yml: -------------------------------------------------------------------------------- 1 | name: Lint Codebase 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | push: 8 | branches: 9 | - main 10 | 11 | permissions: 12 | contents: read 13 | packages: read 14 | statuses: write 15 | 16 | jobs: 17 | lint: 18 | name: Lint Codebase 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Checkout 23 | id: checkout 24 | uses: actions/checkout@v4 25 | with: 26 | fetch-depth: 0 27 | 28 | - name: Lint Codebase 29 | id: super-linter 30 | uses: super-linter/super-linter/slim@v7 31 | env: 32 | DEFAULT_BRANCH: main 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | VALIDATE_ALL_CODEBASE: true 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Diagnostic reports (https://nodejs.org/api/report.html) 6 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # dotenv environment variables file 15 | .env 16 | .env.test 17 | 18 | # OS metadata 19 | .DS_Store 20 | Thumbs.db 21 | 22 | # IDE files 23 | .idea 24 | .vscode 25 | *.code-workspace 26 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 80, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": false, 6 | "singleQuote": true, 7 | "quoteProps": "as-needed", 8 | "jsxSingleQuote": false, 9 | "trailingComma": "none", 10 | "bracketSpacing": true, 11 | "bracketSameLine": true, 12 | "arrowParens": "avoid", 13 | "proseWrap": "always", 14 | "htmlWhitespaceSensitivity": "css", 15 | "endOfLine": "lf" 16 | } 17 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Repository CODEOWNERS 2 | 3 | * @actions/actions-oss-maintainers 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Set the base image to use for subsequent instructions 2 | FROM alpine:3.21 3 | 4 | # Set the working directory inside the container 5 | WORKDIR /usr/src 6 | 7 | # Copy any source file(s) required for the action 8 | COPY entrypoint.sh . 9 | 10 | # Configure the container to be run as an executable 11 | ENTRYPOINT ["/usr/src/entrypoint.sh"] 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright GitHub 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hello, World! Docker Action 2 | 3 | [![GitHub Super-Linter](https://github.com/actions/hello-world-docker-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter) 4 | ![CI](https://github.com/actions/hello-world-docker-action/actions/workflows/ci.yml/badge.svg) 5 | 6 | This action prints `Hello, World!` or `Hello, !` to the log. To 7 | learn how this action was built, see 8 | [Creating a Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action). 9 | 10 | ## Create Your Own Action 11 | 12 | To create your own action, you can use this repository as a template! Just 13 | follow the below instructions: 14 | 15 | 1. Click the **Use this template** button at the top of the repository 16 | 1. Select **Create a new repository** 17 | 1. Select an owner and name for your new repository 18 | 1. Click **Create repository** 19 | 1. Clone your new repository 20 | 21 | > [!CAUTION] 22 | > 23 | > Make sure to remove or update the [`CODEOWNERS`](./CODEOWNERS) file! For 24 | > details on how to use this file, see 25 | > [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners). 26 | 27 | ## Usage 28 | 29 | Here's an example of how to use this action in a workflow file: 30 | 31 | ```yaml 32 | name: Example Workflow 33 | 34 | on: 35 | workflow_dispatch: 36 | inputs: 37 | who-to-greet: 38 | description: Who to greet in the log 39 | required: true 40 | default: 'World' 41 | type: string 42 | 43 | jobs: 44 | say-hello: 45 | name: Say Hello 46 | runs-on: ubuntu-latest 47 | 48 | steps: 49 | # Change @main to a specific commit SHA or version tag, e.g.: 50 | # actions/hello-world-docker-action@e76147da8e5c81eaf017dede5645551d4b94427b 51 | # actions/hello-world-docker-action@v1.2.3 52 | - name: Print to Log 53 | id: print-to-log 54 | uses: actions/hello-world-docker-action@main 55 | with: 56 | who-to-greet: ${{ inputs.who-to-greet }} 57 | ``` 58 | 59 | For example workflow runs, check out the 60 | [Actions tab](https://github.com/actions/hello-world-docker-action/actions)! 61 | :rocket: 62 | 63 | ## Inputs 64 | 65 | | Input | Default | Description | 66 | | -------------- | ------- | ------------------------------- | 67 | | `who-to-greet` | `World` | The name of the person to greet | 68 | 69 | ## Outputs 70 | 71 | | Output | Description | 72 | | ------ | ----------------------- | 73 | | `time` | The time we greeted you | 74 | 75 | ## Test Locally 76 | 77 | After you've cloned the repository to your local machine or codespace, you'll 78 | need to perform some initial setup steps before you can test your action. 79 | 80 | > [!NOTE] 81 | > 82 | > You'll need to have a reasonably modern version of 83 | > [Docker](https://www.docker.com/get-started/) handy (e.g. docker engine 84 | > version 20 or later). 85 | 86 | 1. :hammer_and_wrench: Build the container 87 | 88 | Make sure to replace `actions/hello-world-docker-action` with an appropriate 89 | label for your container. 90 | 91 | ```bash 92 | docker build -t actions/hello-world-docker-action . 93 | ``` 94 | 95 | 1. :white_check_mark: Test the container 96 | 97 | You can pass individual environment variables using the `--env` or `-e` flag. 98 | 99 | ```bash 100 | $ docker run --env INPUT_WHO_TO_GREET="Mona Lisa Octocat" actions/hello-world-docker-action 101 | ::notice file=entrypoint.sh,line=7::Hello, Mona Lisa Octocat! 102 | ``` 103 | 104 | Or you can pass a file with environment variables using `--env-file`. 105 | 106 | ```bash 107 | $ echo "INPUT_WHO_TO_GREET=\"Mona Lisa Octocat\"" > ./.env.test 108 | 109 | $ docker run --env-file ./.env.test actions/hello-world-docker-action 110 | ::notice file=entrypoint.sh,line=7::Hello, Mona Lisa Octocat! 111 | ``` 112 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Hello, World! 2 | description: Greet someone and record the time 3 | author: GitHub Actions 4 | 5 | # Define your inputs here. 6 | inputs: 7 | who-to-greet: 8 | description: Who to greet 9 | required: true 10 | default: World 11 | 12 | # Define your outputs here. 13 | outputs: 14 | time: 15 | description: The time we greeted you 16 | 17 | runs: 18 | using: docker 19 | image: Dockerfile 20 | env: 21 | INPUT_WHO_TO_GREET: ${{ inputs.who-to-greet }} 22 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -l 2 | 3 | # Use INPUT_ to get the value of an input 4 | GREETING="Hello, $INPUT_WHO_TO_GREET!" 5 | 6 | # Use workflow commands to do things like set debug messages 7 | echo "::notice file=entrypoint.sh,line=7::$GREETING" 8 | 9 | # Write outputs to the $GITHUB_OUTPUT file 10 | echo "time=$(date)" >>"$GITHUB_OUTPUT" 11 | 12 | exit 0 13 | --------------------------------------------------------------------------------