Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 600 Bytes

README.md

File metadata and controls

24 lines (18 loc) · 600 Bytes

Inline GitHub Action

[dummy change]

Shows how to use inline Python or e.g. JavaScript code in GitHub actions.

Here, the example task is to derive a Docker tag from GitHub branch name, supporting forks, internal pull requests and pushes.

The Docker tag is a slug from the PR source branch according to Docker rules.

TL;DR / the secret sauce:

- name: Compute Docker tag using Python
  id: python
  run: |
    cat << EOF | python -
    import json, re, os
    event = json.load(open(os.getenv("GITHUB_EVENT_PATH")))
    tag = ...
    print(f"::set-output name=tag::{ tag }")
    EOF