Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "{name}={value}" >> "$GITHUB_OUTPUT"
echo "{environment_variable_name}={value}" >> "$GITHUB_ENV"
27 changes: 27 additions & 0 deletions .github/workflows/DevelopInBranch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# workflow to show how to develop workflows in branches
name: Develop in a branch
on: [pull_request, workflow_dispatch]

jobs:
job1:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- run: |
echo "Workflow triggered in branch '${{ github.ref }}'."

Check failure on line 13 in .github/workflows/DevelopInBranch.yml

View workflow job for this annotation

GitHub Actions / job1

Script Injection

Potential script injection
echo "Workflow triggered by event '${{ github.event_name }}'."
echo "Workflow triggered by actor '${{ github.actor }}''."
# - uses: actions/checkout@v4.2.2
# - uses: devops-actions/actionlint@v0.1.3
# - run: echo "PR title is '${{ github.event.pull_request.title }}'."
- run: |

Check notice on line 19 in .github/workflows/DevelopInBranch.yml

View workflow job for this annotation

GitHub Actions / job1

There is a debug message that is not always visible!
echo "::debug::This is a debug message."
echo "::notice::This is a notice message."

Check warning on line 21 in .github/workflows/DevelopInBranch.yml

View workflow job for this annotation

GitHub Actions / job1

A lot of messages
echo "::warning::This is a warning message."
echo "::error::This is an error message."
- run: |
echo "::notice file=.github/workflows/DevelopInBranch.yml,line=19,col=11,endColumn=51::There is a debug message that is not always visible!"
echo "::warning file=.github/workflows/DevelopInBranch.yml,line=19,endline=21::A lot of messages"
echo "::error title=Script Injection,file=.github/workflows/DevelopInBranch.yml,line=13,col=37,endColumn=68::Potential script injection"
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Action CI
on: [push]

jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- name: Run my own container action
id: my-action
uses: ./
with:
who-to-greet: '@howsen82'
- name: Test the container
if: ${{ steps.my-action.outputs.answer != 42 }}
run: |
echo "::error file=entrypoint.sh,line=4,title=Error in container::The answer was not expected"
exit 1
- name: Set the value
id: step_one
run: |
echo "action_state=yellow" >> "$GITHUB_ENV"
- run: |
echo "${{ env.action_state }}" # This will output 'yellow'
2 changes: 1 addition & 1 deletion 03. Building GitHub Actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ I haven’t included a recipe for adjusting the unit tests in this book as this
npm run bundle
git add .
git commit -m "Fail CI build"
git push set-upstream origin fail-ci-build
git push --set-upstream origin fail-ci-build
gh pr create --fill
```

Expand Down
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Container image that runs your code
# FROM alpine:latest
# CMD echo "Hello World"
FROM alpine:3.21

COPY entrypoint.sh /entrypoint.sh

RUN chmod +x entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]

# docker run $(docker build -q .)
47 changes: 47 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# DockerActionRecipe

A Docker container actions that handles input and output writes a job summary.

## Inputs

## `who-to-greet`

**Required** The name of the person to greet. Default `"World"`.

## Outputs

## `answer`

The answer to the ultimate question of life, the universe, and everything.

## Usage

```yaml
- uses: howsen82/DockerActionRecipe@v1.0
with:
# Required: the person to greet with the action
# Default: World
who-to-greet: ''
```

## Examples

### Simple example

```yaml
- uses: howsen82/DockerActionRecipe@v1.0
with:
who-to-greet: 'Steven Leong'
```

### Example that uses the output parameter

```yaml
- uses: howsen82/DockerActionRecipe@v1.0
id: my-action
with:
who-to-greet: 'Steven Leong'

- name: Output the answer
run: echo "The answer is '${{ steps.my-action.outputs.answer }}'"
```
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Docker Action Recipe'
description: 'Greet someone'

branding:
icon: bell
color: purple
author: 'Steven Leong'

inputs:
who-to-greet:
description: 'Who to greet'
required: true
default: 'World'

outputs:
answer:
description: 'The answer to everything (always 42)'

runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who-to-greet }}
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh -l
echo "Hello $@"
echo "answer=7" >> $GITHUB_OUTPUT
echo "### Hello $@! :rocket:" >> $GITHUB_STEP_SUMMARY

Check failure on line 4 in entrypoint.sh

View workflow job for this annotation

GitHub Actions / ci

Error in container

The answer was not expected
echo "<h3> The answer from Deep Thought is 42 :robot:</h3>" >> $GITHUB_STEP_SUMMARY
Loading