Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable trace based on debug flag #21

Merged
merged 2 commits into from
Jan 27, 2023
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
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- v1
pull_request:

env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}

jobs:
test1:
name: Test Update Needed
Expand Down Expand Up @@ -35,7 +38,7 @@ jobs:
continue-on-error: true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Test Action
id: test
uses: ./
Expand Down Expand Up @@ -100,7 +103,7 @@ jobs:
continue-on-error: true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Test Action
id: test
uses: ./
Expand Down
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,54 @@ build:
> **Note**
>
> If any of the platforms is not present in either the base-image or the image, the action will exit with an error.

## Debugging

To debug the action, you can set the `DEBUG` environment variable to `true` in the workflow file. The variable can be set at any level.

```yaml
name: Check docker image

on:
schedule:
- cron: '0 4 * * *'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check if update available
id: check
uses: lucacome/docker-image-update-checker@v1
with:
base-image: nginx:1.21.0
image: user/app:latest
env:
DEBUG: true
```

To make it more convenient, you can use `${{ secrets.ACTIONS_STEP_DEBUG }}` to enable debugging only when needed.

```yaml
name: Check docker image

on:
schedule:
- cron: '0 4 * * *'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Check if update available
id: check
uses: lucacome/docker-image-update-checker@v1
with:
base-image: nginx:1.21.0
image: user/app:latest
env:
DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
```

This works even when re-running the action with the `Re-run job` button and the `Enable debug logging` checkbox checked.
To read more about debugging actions, see [Debugging actions](https://docs.github.com/en/actions/managing-workflow-runs/enabling-debug-logging#enabling-step-debug-logging).
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
steps:
- id: run-script
run: |
result=$(base=${{ inputs.base-image }} image=${{ inputs.image }} platforms=${{ inputs.platforms }} ${{ github.action_path }}/docker.sh)
result=$(TRACE=${{ env.DEBUG == 'true' && '1' || '0' }} base=${{ inputs.base-image }} image=${{ inputs.image }} platforms=${{ inputs.platforms }} ${{ github.action_path }}/docker.sh)
echo "result=${result}" >>$GITHUB_OUTPUT
shell: bash

Expand Down