forked from ProSE-uoft-org/group-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add auto-release github CI * Give write permission to CI to enable release * Add ci for every push, update auto release name * fix auto-release cicd tag name * Fix auto-release CICD, set date-based tag name for release * Fix CI tag name * Fix auto-release ci tag name * Add script for getting latest release * Modify script for extracting tar.gz static build to target dir
- Loading branch information
1 parent
a9888c8
commit bad7a8b
Showing
6 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Auto Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- auto-release | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup node env 🏗 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
check-latest: true | ||
- name: Bun Setup | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- name: INstall Dependencies | ||
run: bun install | ||
- name: Generate Static Website | ||
run: | | ||
bun generate | ||
mv .output/public static_website | ||
tar -czvf static_website.tar.gz static_website | ||
- name: Set Release Name | ||
id: set_release_name | ||
run: | | ||
echo "RELEASE_NAME=$(date +'%Y-%m-%d %H:%M:%S')" >> "$GITHUB_OUTPUT" | ||
echo "TAG_NAME=v$(date +'%Y-%m-%d-%H-%M-%S')" >> "$GITHUB_OUTPUT" | ||
- name: Create Release | ||
uses: actions/create-release@v1 | ||
id: create_release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.set_release_name.outputs.TAG_NAME }} | ||
release_name: ${{ steps.set_release_name.outputs.RELEASE_NAME }} | ||
draft: false | ||
prerelease: false | ||
- name: upload linux artifact | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./static_website.tar.gz | ||
asset_name: static_website.tar.gz | ||
asset_content_type: application/gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This CI Pipeline is used to make sure the website can be built | ||
name: Build CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup node env 🏗 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
check-latest: true | ||
- name: Bun Setup | ||
uses: oven-sh/setup-bun@v1 | ||
with: | ||
bun-version: latest | ||
- name: INstall Dependencies | ||
run: bun install | ||
- name: Generate Static Website | ||
run: bun generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ sw.* | |
|
||
# Local Netlify folder | ||
.netlify | ||
static_website.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# Replace with your GitHub username and repository name | ||
USERNAME="ProSE-uoft-org" | ||
REPO="group-website" | ||
ASSET_NAME="static_website.tar.gz" | ||
|
||
# Get the download URL for the asset | ||
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/$USERNAME/$REPO/releases/latest" | jq -r '.assets[] | select(.name == "'$ASSET_NAME'") | .browser_download_url') | ||
echo $DOWNLOAD_URL | ||
if [ -n "$DOWNLOAD_URL" ]; then | ||
rm $ASSET_NAME | ||
echo "Downloading $ASSET_NAME..." | ||
# Download the asset using curl | ||
curl -LJO -H 'Accept: application/octet-stream' "$DOWNLOAD_URL" | ||
else | ||
echo "Asset $ASSET_NAME not found in the latest release." | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
ASSET_NAME="static_website.tar.gz" | ||
tar -zxvf $ASSET_NAME | ||
# clear ~/public_html | ||
rm -rf ~/public_html/* | ||
# move the contents of the extracted tarball to ~/public_html | ||
mv static_website/* ~/public_html |