Skip to content

GitHub Action to run the cargo-generate tool in order to simplify testing for template authors

Notifications You must be signed in to change notification settings

cargo-generate/cargo-generate-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cargo-generate GitHub Action

This action runs cargo-generate to expand a template.

Inputs

name

Required

This is the name of the project being expanded.

template

This is the path to the repository holding the template. Defaults to .

arguments

All other arguments that cargo-generate accepts

NOTE: cargo-generate runs with the --silent option, so it will fail if any values are undefined during expansion.

Example:

arguments: "--branch x --define foo=\"value\" --define bar=42"

Example

name: Try to expand local template using cargo-generate
on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      PROJECT_NAME: project-foo 
    steps:
      - uses: actions/checkout@v4
      - uses: cargo-generate/cargo-generate-action@latest
        with:
          name: ${{ env.PROJECT_NAME }}
      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      # we need to move the generated project to a temp folder, away from the template project
      # otherwise `cargo` runs would fail 
      # see https://github.com/rust-lang/cargo/issues/9922
      - run: |
          mv $PROJECT_NAME ${{ runner.temp }}/
          cd ${{ runner.temp }}/$PROJECT_NAME
          cargo check

There is also a full example in this repo under .github/workflows/example-run.yml

About

GitHub Action to run the cargo-generate tool in order to simplify testing for template authors

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published