diff --git a/.github/workflows/template-sync.yml b/.github/workflows/template-sync.yml new file mode 100644 index 0000000000..0ce46b5fa7 --- /dev/null +++ b/.github/workflows/template-sync.yml @@ -0,0 +1,31 @@ +# File: .github/workflows/template-sync.yml +name: Sync Template Updates + +on: + # cronjob trigger + schedule: + - cron: "0 0 * * *" + # manual trigger + workflow_dispatch: +jobs: + repo-sync: + runs-on: ubuntu-latest + # https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs + permissions: + contents: write + pull-requests: write + + steps: + # To use this repository's private action, you must check out the repository + - name: Checkout + uses: actions/checkout@v4 + # https://github.com/actions/checkout#usage + # uncomment if you use submodules within the repository + # with: + # submodules: true + + - name: actions-template-sync + uses: AndreasAugustin/actions-template-sync@v2 + with: + source_repo_path: ebetancourt/full-stack-fastapi-template + upstream_branch: master \ No newline at end of file diff --git a/README.md b/README.md index afe124f3fb..f956706c9e 100644 --- a/README.md +++ b/README.md @@ -54,77 +54,29 @@ ## How To Use It -You can **just fork or clone** this repository and use it as is. +Click the "Use this template" button in the top right corner, and select "Create a new repository" + +![Click the "use this template" button](img/use-this-template.png) ✨ It just works. ✨ ### How to Use a Private Repository -If you want to have a private repository, GitHub won't allow you to simply fork it as it doesn't allow changing the visibility of forks. - -But you can do the following: - -- Create a new GitHub repo, for example `my-full-stack`. -- Clone this repository manually, set the name with the name of the project you want to use, for example `my-full-stack`: +Just select "Private" for the visibility of your repo when creating it from the template. -```bash -git clone git@github.com:fastapi/full-stack-fastapi-template.git my-full-stack -``` - -- Enter into the new directory: - -```bash -cd my-full-stack -``` - -- Set the new origin to your new repository, copy it from the GitHub interface, for example: - -```bash -git remote set-url origin git@github.com:octocat/my-full-stack.git -``` - -- Add this repo as another "remote" to allow you to get updates later: - -```bash -git remote add upstream git@github.com:fastapi/full-stack-fastapi-template.git -``` - -- Push the code to your new repository: - -```bash -git push -u origin master -``` +![Creating a private Repo is easy](img/create-private-repo.png) ### Update From the Original Template -After cloning the repository, and after doing changes, you might want to get the latest changes from this original template. - -- Make sure you added the original repository as a remote, you can check it with: - -```bash -git remote -v - -origin git@github.com:octocat/my-full-stack.git (fetch) -origin git@github.com:octocat/my-full-stack.git (push) -upstream git@github.com:fastapi/full-stack-fastapi-template.git (fetch) -upstream git@github.com:fastapi/full-stack-fastapi-template.git (push) -``` - -- Pull the latest changes without merging: - -```bash -git pull --no-commit upstream master -``` +This repo comes with a "Sync Template Updates" action that runs once a day that checks for updates in the template repo and creates a pull request automatically in your repo if anything has updated -This will download the latest changes from this template without committing them, that way you can check everything is right before committing. +![Screenshot of an automated template update PR](img/automated-template-update-prs.png) -- If there are conflicts, solve them in your editor. +- If there are conflicts, you will need to check out the branch locally, or resolve them in the GitHub web interface. -- Once you are done, commit the changes: +#### For This Action to Work, You Must Allow Actions to Create and Approve PRs -```bash -git merge --continue -``` +![You need to grant GitHub Actions privileges to PRs](img/gh-actions-pr-perms.png) ### Configure @@ -236,4 +188,5 @@ Check the file [release-notes.md](./release-notes.md). ## License + The Full Stack FastAPI Template is licensed under the terms of the MIT license. diff --git a/img/automated-template-update-prs.png b/img/automated-template-update-prs.png new file mode 100644 index 0000000000..5bc7af1579 Binary files /dev/null and b/img/automated-template-update-prs.png differ diff --git a/img/create-private-repo.png b/img/create-private-repo.png new file mode 100644 index 0000000000..0cb25fd603 Binary files /dev/null and b/img/create-private-repo.png differ diff --git a/img/gh-actions-pr-perms.png b/img/gh-actions-pr-perms.png new file mode 100644 index 0000000000..489c97aa53 Binary files /dev/null and b/img/gh-actions-pr-perms.png differ diff --git a/img/use-this-template.png b/img/use-this-template.png new file mode 100644 index 0000000000..b7e40f1f66 Binary files /dev/null and b/img/use-this-template.png differ