Skip to content

PR deployment test #1

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

Open
wants to merge 2 commits into
base: hakyll
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.
# More: https://editorconfig.org/

root = true

[*]
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[Makefile]
indent_style = tab
103 changes: 103 additions & 0 deletions .github/workflows/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/usr/bin/env bash

# Deploy static site to the GitHub pages.

set -eo pipefail

git_repo_root=$(git rev-parse --show-toplevel)
site_src="${git_repo_root}/_site"
gh_pages_root="${git_repo_root}/docs"

# Site built from the main branch will be available at 'https://<domain_name>/'.
# Sites built from other branchs will be available at 'https://<domain_name>/branches/<branch_name>'.
main_git_branch="hakyll"

# replace "/", "#", etc with "-".
slugify() {
echo "$1" | iconv -c -t ascii//TRANSLIT | sed -E 's/[~^]+/-/g' | sed -E 's/[^a-zA-Z0-9]+/-/g' | sed -E 's/^-+|-+$/-/g' | tr A-Z a-z
}

deploy() {
if [[ ! -z "$GITHUB_REF_NAME" ]]; then
# The GITHUB_REF_NAME env variable is available in github actions.
git_branch=$GITHUB_REF_NAME
else
git_branch=$(git branch --show-current)
fi
echo "Current git branch is '${git_branch}'."

git config user.name github-actions
git config user.email github-actions@github.com

git checkout gh-pages
git pull origin gh-pages

if [ "$git_branch" == "$main_git_branch" ]; then
site_dest="${gh_pages_root}"

# Create temporary backup for other branches content.
mv "${gh_pages_root}/branches" .

# Replace site files.
rm -rf "${site_dest}"
mkdir -p "${site_dest}"
cp -a -v ${site_src}/* ${site_dest}/

# Restore temporary backup for other branches content.
mv ./branches "${gh_pages_root}/"
else
site_dest="${gh_pages_root}/branches/$(slugify ${git_branch})"

# Replace site files.
rm -rf "${site_dest}"
mkdir -p "${site_dest}"
cp -a -v ${site_src}/* ${site_dest}/
fi

echo "Updating gh-pages branch."
git add --all
git commit --allow-empty -m "[$(date '+%F %T %Z')] Updated site for the '${git_branch}' branch [ci skip]"
git push --force origin gh-pages
echo "Deployment finished."
}

update_deployments_list() {
github_project_url=$(git remote get-url origin)
if [[ $github_project_url == git@github.com:* ]]; then
github_repo=$(echo ${github_project_url#"git@github.com:"} | sed 's/\.git$//g')
elif [[ $github_project_url == https://github.com/* ]]; then
github_repo=$(echo ${github_project_url#"https://github.com/"} | sed 's/\.git$//g' | sed 's/^\/\///g')
fi

github_repo_owner=$(echo "${github_repo}" | sed 's/\/.*$//g')
github_repo_name=$(echo "${github_repo}" | sed 's/^.*\///g')

deployments_list="DEPLOYMENTS.md"
echo "Updating ${deployments_list}"
rm $deployments_list

# Create a markdown table
touch $deployments_list
echo "# Deployments" >>$deployments_list
echo "" >>$deployments_list
echo "| Branch | Link |" >>$deployments_list
echo "| --- | --- |" >>$deployments_list

main_deployment_url="https://${github_repo_owner}.github.io/${github_repo_name}/"
echo "| [main](https://github.com/${github_repo_owner}/${github_repo_name}/tree/${branch}) | [Open](${main_deployment_url}) |" >>$deployments_list

remote_branches=$(git ls-remote --heads origin | sed 's?.*refs/heads/??')
echo "$remote_branches" | while IFS= read -r branch; do
safe_branch=$(slugify $branch)
deployment_url="https://${github_repo_owner}.github.io/${github_repo_name}/branches/${safe_branch}"
echo "| [${branch}](https://github.com/${github_repo_owner}/${github_repo_name}/tree/${branch}) | [Open](${deployment_url}) |" >>$deployments_list
done

# Update gh-pages branch
git add --all
git commit --allow-empty -m "Update ${deployments_list}"
git push --force origin gh-pages
}

deploy
update_deployments_list
28 changes: 10 additions & 18 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ name: CI
on:
# Triggers the workflow on push or pull request events but only for the hakyll branch
push:
branches: [ hakyll ]
# branches:
branches-ignore:
- gh-pages
pull_request:
branches: [ hakyll ]
branches-ignore:
- gh-pages

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand Down Expand Up @@ -48,21 +51,10 @@ jobs:
- name: Build dependencies
run: stack build --system-ghc --only-dependencies

- name: Build site executable
run: stack build --system-ghc
- name: Build
run: |
stack build --system-ghc
stack exec --system-ghc site build

# Runs a set of commands using the runners shell
- name: Deploy
run: |
git config user.name github-actions
git config user.email github-actions@github.com
stack exec --system-ghc site rebuild
git checkout main
git pull --rebase
# Overwrite existing files with new files
cp -a -v _site/. .
# Commit
git add --all
git commit -m "[`date '+%F %T %Z'`] New release [ci skip]"
# Push
git push origin main:main
run: ./.github/workflows/deploy.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This repository is for the [haskell.foundation](https://haskell.foundation) webs
- [Building](#building)
- [CI](#ci)
- [License](#license)

- [Dev Deployments List](https://github.com/haskellfoundation/haskellfoundation.github.io/blob/gh-pages/DEPLOYMENTS.md)

## Building

Expand Down
4 changes: 2 additions & 2 deletions donations/sponsors/flipstone.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: FlipStone
logo: /assets/images/sponsors/flipstone/flipstone-683.png
srcset: /assets/images/sponsors/flipstone/flipstone-200.png 200w, /assets/images/sponsors/flipstone/flipstone-400.png 400w, /assets/images/sponsors/flipstone/flipstone-683.png 683w
logo: ./assets/images/sponsors/flipstone/flipstone-683.png
srcset: ./assets/images/sponsors/flipstone/flipstone-200.png 200w, ./assets/images/sponsors/flipstone/flipstone-400.png 400w, ./assets/images/sponsors/flipstone/flipstone-683.png 683w
externalUrl: https://flipstone.com/
level: Functor
---
4 changes: 2 additions & 2 deletions donations/sponsors/github.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: GitHub
logo: /assets/images/sponsors/github/github-683.png
srcset: /assets/images/sponsors/github/github-200.png 200w, /assets/images/sponsors/github/github-400.png 400w, /assets/images/sponsors/github/github-683.png 683w
logo: ./assets/images/sponsors/github/github-683.png
srcset: ./assets/images/sponsors/github/github-200.png 200w, ./assets/images/sponsors/github/github-400.png 400w, ./assets/images/sponsors/github/github-683.png 683w
externalUrl: https://github.com/
level: Monad
---
4 changes: 2 additions & 2 deletions donations/sponsors/iohk.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: IOHK
logo: /assets/images/sponsors/iohk/iohk-683.png
srcset: /assets/images/sponsors/iohk/iohk-200.png 200w, /assets/images/sponsors/iohk/iohk-400.png 400w, /assets/images/sponsors/iohk/iohk-683.png 683w
logo: ./assets/images/sponsors/iohk/iohk-683.png
srcset: ./assets/images/sponsors/iohk/iohk-200.png 200w, ./assets/images/sponsors/iohk/iohk-400.png 400w, ./assets/images/sponsors/iohk/iohk-683.png 683w
externalUrl: https://iohk.io/
level: Monad
---
4 changes: 2 additions & 2 deletions donations/sponsors/obsidian.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Obsidian Systems
logo: /assets/images/sponsors/obsidian-systems/obsidian-systems-683.png
srcset: /assets/images/sponsors/obsidian-systems/obsidian-systems-200.png 200w, /assets/images/sponsors/obsidian-systems/obsidian-systems-400.png 400w, /assets/images/sponsors/obsidian-systems/obsidian-systems-683.png 683w
logo: ./assets/images/sponsors/obsidian-systems/obsidian-systems-683.png
srcset: ./assets/images/sponsors/obsidian-systems/obsidian-systems-200.png 200w, ./assets/images/sponsors/obsidian-systems/obsidian-systems-400.png 400w, ./assets/images/sponsors/obsidian-systems/obsidian-systems-683.png 683w
externalUrl: https://obsidian.systems/
level: Applicative
---
4 changes: 2 additions & 2 deletions donations/sponsors/tweag.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Tweag
logo: /assets/images/sponsors/tweag/tweag-683.png
srcset: /assets/images/sponsors/tweag/tweag-200.png 200w, /assets/images/sponsors/tweag/tweag-400.png 400w, /assets/images/sponsors/tweag/tweag-683.png 683w
logo: ./assets/images/sponsors/tweag/tweag-683.png
srcset: ./assets/images/sponsors/tweag/tweag-200.png 200w, ./assets/images/sponsors/tweag/tweag-400.png 400w, ./assets/images/sponsors/tweag/tweag-683.png 683w
externalUrl: https://tweag.io/
level: Applicative
---
4 changes: 2 additions & 2 deletions donations/sponsors/welltyped.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Well-Typed
logo: /assets/images/sponsors/well-typed/well-typed-683.png
srcset: /assets/images/sponsors/well-typed/well-typed-200.png 200w, /assets/images/sponsors/well-typed/well-typed-400.png 400w, /assets/images/sponsors/well-typed/well-typed-683.png 683w
logo: ./assets/images/sponsors/well-typed/well-typed-683.png
srcset: ./assets/images/sponsors/well-typed/well-typed-200.png 200w, ./assets/images/sponsors/well-typed/well-typed-400.png 400w, ./assets/images/sponsors/well-typed/well-typed-683.png 683w
externalUrl: https://well-typed.com/
level: Applicative
---
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="border border-purple-100 p-1 lg:p-3">
<div class="border border-purple-50 p-16 flex flex-col items-center text-center">
<h1 class="mb-4 text-3xl-6xl font-w-800">The Haskell Foundation</h1>
<h3 class="mb-4 text-xl text-gray-500">Amplify Haskell’s impact on humanity.</h3>
<h3 class="mb-4 text-xl text-gray-500">Amplify Haskell’s impact on pr-deployment-test.</h3>
<div class="text-gray-500">An independent, non-profit organization dedicated to broadening the adoption of Haskell, by supporting its ecosystem of tools, libraries, education, and research.</div>
</div>
</div>
Expand Down