diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5730fb3..2442695 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,44 +1,43 @@ +name: CI on: - push - -name: ci - + pull_request: + push: jobs: - build: + build-tag-push-deploy: runs-on: ubuntu-latest + if: > + github.ref == 'refs/heads/main' || + github.ref == 'refs/heads/dev' steps: - - uses: actions/checkout@v2 - with: - # submodules: true # Fetch Hugo themes (true OR recursive) - fetch-depth: 1 - + - name: Checkout code + uses: actions/checkout@v2 - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: cmu-delphi-deploy-machine password: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_PAT }} - - - name: Build, tag, and push image to Github - env: - DEVOPS_DOCKER_FILE: ./devops/Dockerfile + - name: Build, tag, and push image to GitHub Container Registry + id: image run: | baseRef="${GITHUB_REF#*/}" baseRef="${baseRef#*/}" case "${baseRef}" in main) - imageTag="latest" + image_tag="latest" ;; *) - imageTag="${baseRef//\//_}" # replace `/` with `_` in branch name + image_tag="${baseRef//\//_}" # replace `/` with `_` in branch name ;; esac - echo "using tag: --${imageTag}--" - docker build -t ghcr.io/${{ github.repository }}:$imageTag --file ${DEVOPS_DOCKER_FILE} . - docker push ghcr.io/${{ github.repository }}:$imageTag - - # trigger a webhook update + cd ${{ github.workspace }} + echo "using tag: --${image-tag}--" + docker build -t ghcr.io/${{ github.repository }}:${image_tag} --file ./devops/Dockerfile . + docker push ghcr.io/${{ github.repository }}:${image_tag} + echo "IMAGE_TAG=${image_tag}" >> $GITHUB_OUTPUT + - name: Trigger smee.io webhook to deploy new container image + run: | curl -H "Authorization: Bearer ${{ secrets.DELPHI_DEPLOY_WEBHOOK_TOKEN }}" \ -X POST ${{ secrets.DELPHI_DEPLOY_WEBHOOK_URL }} \ -H "Content-Type: application/x-www-form-urlencoded" \ - -d "repository=ghcr.io/${{ github.repository }}&tag=$imageTag" + -d "repository=ghcr.io/${{ github.repository }}&tag=${{ steps.image.outputs.IMAGE_TAG }}" diff --git a/README.md b/README.md index b7d0a11..d50340a 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,39 @@ -# Status - -[![Deploy Status](https://delphi.midas.cs.cmu.edu/~automation/public/github_deploy_repo/badge.php?repo=cmu-delphi/www-epicast/dev)](#) # About -This is the **development** version of the website. +The Crowdcast website for collecting flu forecasts. (Previously known as +Epicast.) + +The site is live at . + +# Branches + +The website is deployed to two separate environments: `staging` and `production`. The code for those environments is kept in the +[`dev`](https://github.com/cmu-delphi/www-epicast/tree/dev) and +[`main`](https://github.com/cmu-delphi/www-epicast/tree/main) branches, +respectively. + +## `dev` branch + +The `dev` branch is deployed to a Delphi-internal development environment where we can iterate quickly without worry of breaking the production site. + +## `main` branch + +The `main` branch is deployed to a public-facing production environment. It +should contain only tested and reliable code. + +## Process + +**`main` should not be updated while a forecasting round is active** (i.e. +Friday through Monday), except in case of a critical bugfix. + +Basic develop changes -> deploy/review in staging -> release to production workflow: + +- Start by creating a **[bug|fix|feature|etc]** branch based on `dev`. +- Make a PR and tag a reviewer with your changes against `dev`. Once apporved and merged this will trigger CI to deploy the application at https://staging.delphi.cmu.edu/crowdcast. +- Once staging is reviewed and deemed acceptable, make a PR against `main` and tag a reviewer. Once this is approved and merged the production version of the application will be available at https://delphi.cmu.edu/crowdcast -1. it is generally safe to make changes here at any time, as they will not -affect the production environment -2. changes should be merged from this branch into -[the prod branch](https://github.com/cmu-delphi/www-epicast/tree/prod), -except for production-specific configuration +# Development -See -[the master branch README.md](https://github.com/cmu-delphi/www-epicast/blob/master/README.md) -for more information. +For developing the website, see the +[epicast development guide](docs/epicast_development.md). diff --git a/site/common/header.php b/site/common/header.php index 792cafe..e91b33a 100644 --- a/site/common/header.php +++ b/site/common/header.php @@ -20,7 +20,7 @@ - +