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

ci: Use GitHub Actions to perform deployment #53

Conversation

matthewfeickert
Copy link
Contributor

@matthewfeickert matthewfeickert commented Mar 7, 2024

Edits PR #52 (though if it is perferable I can just rebase this against main and supersede it instead)

  • Run on push events to 'main' as the default branch has been renamed from 'master'.
  • Add running the build job on pull_request events to allow testing builds of the website in advance.
  • Scope concurrency to the workflow level, which allows for per branch runs to not conflict.
  • Split the workflow into a build and deploy job. In the build job have the built website be uploaded as a run artifact. In the deploy job this artifact is then downloaded and and deployed to GitHub Pages.
    • For the deploy job, set the permissions to allow for the default GITHUB_TOKEN to perform the deployment.
    • Use the github-pages environment as required by GitHub Actions.
    • Run the deploy job on either:
      • push events to main (a merged PR)
      • workflow_dispatch events that happen on any branch, to allow for hotfixing

This also allows us to not use ghp-import which is a project that is unmatained.

* Run on push events to 'main' as the default branch has been renamed from 'master'.
* Add running the build job on pull_request events to allow testing builds of the
  website in advance.
* Scope concurrency to the workflow level, which allows for per branch runs to not conflict.
* Split the workflow into a build and deploy job. In the build job have the built website
  be uploaded as a run artifact. In the deploy job this artifact is then downloaded
  and and deployed to GitHub Pages.
   - For the deploy job, set the permissions to allow for the default GITHUB_TOKEN to perform
     the deployment.
   - Use the github-pages environment as required by GitHub Actions.
   - Run the deploy job on either:
      * push events to main (a merged PR)
      * workflow_dispatch events that happen on any branch, to allow for hotfixing
Copy link
Contributor Author

@matthewfeickert matthewfeickert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achabotl @tkoyama010 some comments to hopefully make this review more clear.

On my fork I also have this deployed from triggers from a debug example/show-deployment branch using this workflow with https://matthewfeickert.github.io/conference.scipy.org/

Comment on lines +55 to +58
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +60 to +62
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Copy link
Contributor Author

@matthewfeickert matthewfeickert Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.f. https://github.com/actions/deploy-pages?tab=readme-ov-file#usage again for why these choices but make sure to switch to using GitHub Actions under https://github.com/scipy-conference/conference.scipy.org/settings/pages

image

(for the conference website you also are going to want to make sure you're using the custom domain as well.)

and then set whatever branch protection rules you'd like for the github-pages environment under https://github.com/scipy-conference/conference.scipy.org/settings/environments

group: "pages"
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fine to cancel in progress if you scope to the branch level like is done here. If you are firing off another event trigger on the same branch the goal is to overwrite the previous anyway, so no harm in canceling.

@@ -3,22 +3,18 @@ name: Deploy to GitHub Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
branches: ["main"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default branch name is main

@achabotl achabotl merged commit 749a836 into scipy-conference:publish-gh-pages Mar 7, 2024
2 checks passed
@tkoyama010
Copy link
Member

Sorry for the delay. Thanks for this.

@matthewfeickert matthewfeickert deleted the ci/use-github-actions-for-deployment branch March 7, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants