Skip to main content

No project description provided

Project description

release-engineers/action-template

Status: Production ready PyPI version

action-template runs the Jinja2 templating engine against any given files during a GitHub workflow, and makes the GitHub context available to it.

Usage

action-template can be used as a GitHub Action;

name: Generate README.md

on:
  push:
    branches:
      - master
    paths:
      - 'README.md.template'
  workflow_dispatch:

defaults:
  run:
    shell: bash --login {0}

permissions:
  contents: write

jobs:
  run-templating:
    runs-on: ubuntu-latest
    steps:
      - uses: release-engineers/action-setup-bash@v1
      - uses: actions/checkout@v2
      - uses: release-engineers/action-template@v1
        with:
          source: 'README.md.template'
          target: 'README.md'
      - run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git add README.md
          git commit --no-verify -m "docs: Regenerate README.md"
          
          # rebase and push in a retry loop
          for i in {1..5}; do
            git pull --rebase && git push && break || sleep 1
          done

Features

GitHub Context

The GitHub context available to workflows is also available to templates like so;

{{ github.repository }}

When evaluated becomes:

release-engineers/action-template

Load Files

The example workflow under the Usage paragraph was loaded using;

{{ load('.github/workflows/example.yml') }}

Load JSON

Parse and handle JSON data from files in the working directory like so;

{{ load_json('tests/data/data.json').info.from_json }}

When evaluated becomes:

This text is a JSON value in a file.

Load YAML

Parse and handle YAML data from files in the working directory like so;

{{ load_yaml('tests/data/data.yml').info.from_yaml }}

When evaluated becomes:

This text is a YAML value in a file

Load Markdown Table of Contents as HTML

Parse and obtain a Markdown table of contents from files in the working directory like so;

{{ load_markdown_toc('tests/data/data.md') }}

When evaluated becomes:

<div class="toc">
<ul>
<li><a href="#header-one">Header One</a><ul>
<li><a href="#header-two">Header Two</a><ul>
<li><a href="#header-three">Header Three</a></li>
<li><a href="#header-three-two">Header Three, Two</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>

Load Markdown Table of Contents as data

Parse and handle Markdown table of contents data from files in the working directory like so;

{{ load_markdown_toc_tokens('tests/data/data.md') }}

When evaluated becomes:

[{'level': 1, 'id': 'header-one', 'name': 'Header One', 'children': [{'level': 2, 'id': 'header-two', 'name': 'Header Two', 'children': [{'level': 3, 'id': 'header-three', 'name': 'Header Three', 'children': []}, {'level': 3, 'id': 'header-three-two', 'name': 'Header Three, Two', 'children': []}]}]}]

Contributing

This is a Python Poetry project using Fire. See Poetry for more information.

Development requires:

See app.sh for building, running and releasing the application.

Links

This project was created using template-poetry.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

re_action_template-2.0.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file re_action_template-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: re_action_template-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for re_action_template-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8cc170ca1c4d55032f1f7a307dd65dbb8ad0097a1ff8edd5ca7b1b9f42192b66
MD5 2efbecb57acf17adefef5d8f5e797319
BLAKE2b-256 e0c366ccf22d6f1b549c69fc3005ce3d3c76f0c8c322c26f4f2ed72610b0e75f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page