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

GitHub Action workflows should not be included when using the repository template #233

Closed
caendesilva opened this issue Dec 1, 2023 · 2 comments · Fixed by #234 or #257
Closed
Labels
bug Something isn't working

Comments

@caendesilva
Copy link
Member

Issue description

Issue to track a bug in GitHub, where it's not possible to exclude files from repository templates. See https://github.com/orgs/community/discussions/22183

In this template, we run tests on the project, but the workflow shouldn't be present in the release when users create a repo based on the template. I don't want to use up their action minutes for something that they don't need. Considering forks don't even run workflows by default, why would repo templates be different?

@caendesilva caendesilva added the bug Something isn't working label Dec 1, 2023
@caendesilva
Copy link
Member Author

One possible fix is to add another workflow

# filepath .github/workflows/first-time-setup.yml

name: first-time-setup
run-name: first time setup of repo

on:
  # run when branch created (repo generated from template)
  create:

# only keep latest run of this workflow
concurrency:
  group: first-time-setup
  cancel-in-progress: true

permissions: 
  actions: write
  checks: write
  contents: write
  
jobs:
  first-time-setup:
    # ensure run only once, when repo generated
    if: github.run_number == 1
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

      - name: Remove unneeded files
        run: rm -rf .github/workflows
        
      - name: Commit changed files
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: "Setup repo"

This does this:

image

But it doesn't feel right. Maybe a better solution is to just not run the workflow outside the repo.

@caendesilva
Copy link
Member Author

Reopening as I realized not only workflows are affected by this, the licence files among others are also added. We don't want to accidentally licence someones proprietary app as MIT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant