[GH-ISSUE #179] how to trigger a tag event locally #123

Closed
opened 2026-03-01 21:40:23 +03:00 by kerem · 21 comments
Owner

Originally created by @jonyhy96 on GitHub (Apr 1, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/179

act version 0.2.7

workflow:

name: postgres action 

on:
  push:
    branches:
      - master
    tags:
      - v*

jobs:
  build-and-push:
    runs-on: ubuntu-16.04
    timeout-minutes: 3
    steps:
    - name: Checkout
      uses: actions/checkout@v2

    - name: build and push image
      uses: docker/build-push-action@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}
        repository: byzanteam/nitrogen-postgres
        registry: ${{ secrets.DOCKER_REGISTRY }}
        tag_with_ref: true

tag.json

{
    "ref": "refs/tags/v0.0.1"
}

log:

DEBU[0000] Loading workflows from '/PATH/.github/workflows' 
DEBU[0000] Reading workflow '/PATH/.github/workflows/main.yml' 
DEBU[0000] Using detected workflow event: push          
DEBU[0000] Planning event: push                         
DEBU[0000] Reading event.json from /PATH/tag.json 
DEBU[0000] Loading slug from git directory '/PATH/.git' 
DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 
DEBU[0000] Loading revision from git directory '/PATH/.git' 
DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 
DEBU[0000] HEAD points to '7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
[postgres action/build-and-push] 🚀  Start image=node:12.6-stretch-slim
DEBU[0000] Loading slug from git directory '/PATH/.git' 
DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 
DEBU[0000] Loading revision from git directory '/PATH/.git' 
DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 
DEBU[0000] HEAD points to '7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3' 
DEBU[0000] HEAD matches refs/heads/master               
DEBU[0000] using github ref: refs/heads/master          
[postgres action/build-and-push]   🐳  docker pull node:12.6-stretch-slim

questions:

  1. how to trigger a tag event locally?
  2. Is there an example of this?
Originally created by @jonyhy96 on GitHub (Apr 1, 2020). Original GitHub issue: https://github.com/nektos/act/issues/179 act version 0.2.7 workflow: ```yml name: postgres action on: push: branches: - master tags: - v* jobs: build-and-push: runs-on: ubuntu-16.04 timeout-minutes: 3 steps: - name: Checkout uses: actions/checkout@v2 - name: build and push image uses: docker/build-push-action@v1 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} repository: byzanteam/nitrogen-postgres registry: ${{ secrets.DOCKER_REGISTRY }} tag_with_ref: true ``` tag.json ```json { "ref": "refs/tags/v0.0.1" } ``` log: ``` DEBU[0000] Loading workflows from '/PATH/.github/workflows' DEBU[0000] Reading workflow '/PATH/.github/workflows/main.yml' DEBU[0000] Using detected workflow event: push DEBU[0000] Planning event: push DEBU[0000] Reading event.json from /PATH/tag.json DEBU[0000] Loading slug from git directory '/PATH/.git' DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 DEBU[0000] Loading revision from git directory '/PATH/.git' DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 DEBU[0000] HEAD points to '7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3' DEBU[0000] HEAD matches refs/heads/master DEBU[0000] using github ref: refs/heads/master [postgres action/build-and-push] 🚀 Start image=node:12.6-stretch-slim DEBU[0000] Loading slug from git directory '/PATH/.git' DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 DEBU[0000] Loading revision from git directory '/PATH/.git' DEBU[0000] Found revision: 7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3 DEBU[0000] HEAD points to '7c6d9e0bd6b4fcd2dfe32296e8298ae4c32ac2d3' DEBU[0000] HEAD matches refs/heads/master DEBU[0000] using github ref: refs/heads/master [postgres action/build-and-push] 🐳 docker pull node:12.6-stretch-slim ``` questions: 1. how to trigger a tag event locally? 2. Is there an example of this?
kerem 2026-03-01 21:40:23 +03:00
Author
Owner

@mced commented on GitHub (Apr 1, 2020):

@jonyhy96 Did you try to tag your code ?

<!-- gh-comment-id:607085986 --> @mced commented on GitHub (Apr 1, 2020): @jonyhy96 Did you try to tag your code ?
Author
Owner

@jonyhy96 commented on GitHub (Apr 1, 2020):

@jonyhy96 Did you try to tag your code ?

I tried tag locally and check out to the tag with:

git tag -a v0.0.1 -m "something"
git checkout tags/v0.0.1 -b v0.0.1

But act still has the same log as above.

<!-- gh-comment-id:607161146 --> @jonyhy96 commented on GitHub (Apr 1, 2020): > @jonyhy96 Did you try to tag your code ? I tried tag locally and check out to the tag with: ```bash git tag -a v0.0.1 -m "something" git checkout tags/v0.0.1 -b v0.0.1 ``` But act still has the same log as above.
Author
Owner

@mced commented on GitHub (Apr 2, 2020):

A workaround I personally use is to trigger an action (locally and on ga) on tags is to use a conditional like this but that won't work anymore on master pushes only for tags...

jobs:
  build-and-push:
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-16.04
    ...
<!-- gh-comment-id:607790409 --> @mced commented on GitHub (Apr 2, 2020): A workaround I personally use is to trigger an action (locally and on ga) on tags is to use a conditional like this but that won't work anymore on master pushes only for tags... ```yaml jobs: build-and-push: if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-16.04 ... ```
Author
Owner

@jonyhy96 commented on GitHub (Apr 2, 2020):

A workaround I personally use is to trigger an action (locally and on ga) on tags is to use a conditional like this but that won't work anymore on master pushes only for tags...

jobs:
  build-and-push:
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-16.04
    ...

I can't find any code handles the environment loads from --env-file flag.
Is that a bug or am i missing something?
If we can use the --env-file flag, maybe we can specific GITHUB_REF to fake a tag event.

<!-- gh-comment-id:607845512 --> @jonyhy96 commented on GitHub (Apr 2, 2020): > A workaround I personally use is to trigger an action (locally and on ga) on tags is to use a conditional like this but that won't work anymore on master pushes only for tags... > > ```yaml > jobs: > build-and-push: > if: startsWith(github.ref, 'refs/tags/v') > runs-on: ubuntu-16.04 > ... > ``` I can't find any code handles the environment loads from `--env-file` flag. Is that a bug or am i missing something? If we can use the `--env-file` flag, maybe we can specific `GITHUB_REF` to fake a tag event.
Author
Owner

@cplee commented on GitHub (Apr 23, 2020):

act should parse the event json and use for on: branches and tags

<!-- gh-comment-id:618192460 --> @cplee commented on GitHub (Apr 23, 2020): act should parse the event json and use for `on:` branches and tags
Author
Owner

@third774 commented on GitHub (Apr 27, 2020):

@cplee is there an example somewhere of what the JSON shape should be for this?

<!-- gh-comment-id:620042539 --> @third774 commented on GitHub (Apr 27, 2020): @cplee is there an example somewhere of what the JSON shape should be for this?
Author
Owner

@leepowelldev commented on GitHub (May 11, 2020):

@cplee I'd also be keen to know the shape needed to for event.json to simlulate a tag push

<!-- gh-comment-id:626898308 --> @leepowelldev commented on GitHub (May 11, 2020): @cplee I'd also be keen to know the shape needed to for `event.json` to simlulate a tag push
Author
Owner

@cplee commented on GitHub (May 13, 2020):

@third774 and @leepowelldev - all events are documented, for example here's the link for push

https://developer.github.com/v3/activity/events/types/#pushevent

<!-- gh-comment-id:628276951 --> @cplee commented on GitHub (May 13, 2020): @third774 and @leepowelldev - all events are documented, for example here's the link for `push` https://developer.github.com/v3/activity/events/types/#pushevent
Author
Owner

@github-actions[bot] commented on GitHub (Jul 13, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:657298328 --> @github-actions[bot] commented on GitHub (Jul 13, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@m0un10 commented on GitHub (Sep 1, 2020):

@cplee I tried the exact push event from the github documentation but it ignored the branch set and just used my actual branch. Is simulating the push branch supported?

<!-- gh-comment-id:684153633 --> @m0un10 commented on GitHub (Sep 1, 2020): @cplee I tried the exact push event from the github documentation but it ignored the branch set and just used my actual branch. Is simulating the push branch supported?
Author
Owner

@github-actions[bot] commented on GitHub (Nov 1, 2020):

Issue is stale and will be closed in 7 days unless there is new activity

<!-- gh-comment-id:720006102 --> @github-actions[bot] commented on GitHub (Nov 1, 2020): Issue is stale and will be closed in 7 days unless there is new activity
Author
Owner

@catthehacker commented on GitHub (Nov 24, 2020):

From what I understand act doesn't know how to trigger tag push as of right now. The only reason why pull_request is understood via --eventpath/-e is because it's defined:
github.com/nektos/act@b3299ecd30/pkg/runner/run_context.go (L471-L474)
I've added the option to push specific tag via --ref, e.g. --ref 'refs/tags/v3.3'

<!-- gh-comment-id:733284406 --> @catthehacker commented on GitHub (Nov 24, 2020): From what I understand `act` doesn't know how to trigger tag push as of right now. The only reason why `pull_request` is understood via `--eventpath`/`-e` is because it's defined: https://github.com/nektos/act/blob/b3299ecd30bab3e69c92a04c96de1fb25863aa96/pkg/runner/run_context.go#L471-L474 ~~I've added the option to push specific tag via `--ref`, e.g. `--ref 'refs/tags/v3.3'`~~
Author
Owner

@m0un10 commented on GitHub (Nov 25, 2020):

Thanks @CatTheHacker. That is useful to know. Are you planning to raise a PR?

<!-- gh-comment-id:733350628 --> @m0un10 commented on GitHub (Nov 25, 2020): Thanks @CatTheHacker. That is useful to know. Are you planning to raise a PR?
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:761279638 --> @github-actions[bot] commented on GitHub (Jan 16, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@pwoolvett commented on GitHub (Feb 11, 2021):

unstale

<!-- gh-comment-id:777779961 --> @pwoolvett commented on GitHub (Feb 11, 2021): unstale
Author
Owner

@mxxnhxTW commented on GitHub (Mar 10, 2021):

Is the code that @catthehacker commented merged to the latest version of act?
It still doesn't work properly for push tag event on act version v0.2.20

<!-- gh-comment-id:795289159 --> @mxxnhxTW commented on GitHub (Mar 10, 2021): Is the code that @catthehacker commented merged to the latest version of act? It still doesn't work properly for push tag event on act version v0.2.20
Author
Owner

@giggio commented on GitHub (Aug 9, 2021):

I just tried act --ref 'refs/tags/2.3.1' and it still doesn't work, I guess it is not yet implemented.

<!-- gh-comment-id:895533006 --> @giggio commented on GitHub (Aug 9, 2021): I just tried `act --ref 'refs/tags/2.3.1'` and it still doesn't work, I guess it is not yet implemented.
Author
Owner

@catthehacker commented on GitHub (Aug 9, 2021):

outdated

<!-- gh-comment-id:895535646 --> @catthehacker commented on GitHub (Aug 9, 2021): ~~outdated~~
Author
Owner

@rooom13 commented on GitHub (Feb 6, 2022):

Did anybody find a way of passing any arguments for testing different github.ref values?

<!-- gh-comment-id:1030890506 --> @rooom13 commented on GitHub (Feb 6, 2022): Did anybody find a way of passing any arguments for testing different `github.ref` values?
Author
Owner

@catthehacker commented on GitHub (Mar 1, 2022):

Did anybody find a way of passing any arguments for testing different github.ref values?

https://github.com/nektos/act#events

<!-- gh-comment-id:1055810124 --> @catthehacker commented on GitHub (Mar 1, 2022): > Did anybody find a way of passing any arguments for testing different `github.ref` values? https://github.com/nektos/act#events
Author
Owner

@catthehacker commented on GitHub (Mar 1, 2022):

Add simple example: https://github.com/nektos/act/wiki/Beginner's-guide#using-event-file-to-provide-complete-event-payload

<!-- gh-comment-id:1055830753 --> @catthehacker commented on GitHub (Mar 1, 2022): Add simple example: https://github.com/nektos/act/wiki/Beginner's-guide#using-event-file-to-provide-complete-event-payload
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#123
No description provided.