In this exercise, you will create a workflow that uses GitHub Pages to deploy a static site online.
The index.html
file is already provided in the exercise
folder.
- In the
.github/workflows/
directory, create a new file namedexercise-4.yml
.
- Give the workflow a name:
"Deploy Static Site"
. - Trigger the workflow: Set it to run when pushing to the
main
branch. - Add the following steps:
- Checkout the repository code using
actions/checkout@v3
. - Deploy to GitHub Pages using
peaceiris/actions-gh-pages@v3
. - Set the
publish_dir
to point to theexercise
directory (whereindex.html
is located).
- Checkout the repository code using
- Create a branch with the name gh-pages if not present
- Go to your repository Settings.
- Select Pages and select the Source to be Deploy from a branch
- Set the branch to the
gh-pages
branch with root.
- The
peaceiris/actions-gh-pages@v3
action simplifies deployment by handling the publishing process. - Make sure to commit and push the
exercise-4.yml
file to trigger the workflow.
Good luck, and happy coding! Next Exercise