Skip to content

Commit

Permalink
Merge pull request #3 from pl-strflt/release-v1.1.3
Browse files Browse the repository at this point in the history
feat: add .github/actions/github
  • Loading branch information
galargh authored Mar 10, 2023
2 parents 200ee9a + ccf3d39 commit 2296897
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
31 changes: 31 additions & 0 deletions .github/actions/github/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 'Docker Container Action'
description: 'A reimplementation of docker container action'
inputs:
github:
description: 'The GitHub context'
required: true
default: ${{ toJSON(github) }}
outputs:
action_repository:
description: 'The GitHub action repository name'
value: ${{ steps.action.outputs.action_repository }}
action_ref:
description: 'The GitHub action repository ref'
value: ${{ steps.action.outputs.action_ref }}
runs:
using: 'composite'
steps:
- id: action
env:
ACTION_PATH: ${{ fromJSON(inputs.github).action_path }}
REPOSITORY: ${{ fromJSON(inputs.github).repository }}
SHA: ${{ fromJSON(inputs.github).sha }}
run: |
if [[ $ACTION_PATH == */_actions/* ]]; then
echo "action_repository=$(echo ${ACTION_PATH#*/_actions/} | cut -d/ -f1-2)" >> $GITHUB_OUTPUT
echo "action_ref=$(echo ${ACTION_PATH#*/_actions/} | cut -d/ -f3)" >> $GITHUB_OUTPUT
else
echo "action_repository=$GITHUB_REPOSITORY" >> $GITHUB_OUTPUT
echo "action_ref=$GITHUB_SHA" >> $GITHUB_OUTPUT
fi
shell: bash
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [1.1.3] - 2023-03-10
### Added
- Added `.github/actions/github` composite action to infer GitHub action repository and ref from GitHub action path

## [1.1.2] - 2023-03-10
### Changed
- Do not pass internal inputs to the docker run step
Expand Down
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,14 @@ When the Docker Container Action runs, it first checks if the specified image ex
This action is commonly used inside a composite action. For example, if the composite action is defined in the `github/example` repository, you could use the Docker Container Action in a step with the following syntax:

```yml
# This step is required because GitHub Actions doesn't set GITHUB_ACTION_REPOSITORY nor GITHUB_ACTION_REF properly :(
- id: action
run: |
if [[ $GITHUB_ACTION_PATH == */_actions/* ]]; then
echo "repository=$(echo ${GITHUB_ACTION_PATH#*/_actions/} | cut -d/ -f1-2)" >> $GITHUB_OUTPUT
echo "ref=$(echo ${GITHUB_ACTION_PATH#*/_actions/} | cut -d/ -f3)" >> $GITHUB_OUTPUT
else
echo "repository=$GITHUB_REPOSITORY" >> $GITHUB_OUTPUT
echo "ref=$GITHUB_SHA" >> $GITHUB_OUTPUT
fi
shell: bash
- id: github
name: Infer GitHub action repository and ref from GitHub action path
uses: pl-strflt/docker-container-action/.github/actions/github@v1
- name: Run Docker container
uses: pl-strflt/docker-container-action@v1
with:
repository: ${{ env.GITHUB_ACTION_REPOSITORY }}
ref: ${{ env.GITHUB_ACTION_REF }}
repository: ${{ steps.github.outputs.action_repository }}
ref: ${{ steps.github.outputs.action_ref }}
opts: --network=host
```
Expand Down

0 comments on commit 2296897

Please sign in to comment.