diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..eb19541 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..eae20a9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.gitignore b/.gitignore index 1c1c461..7ed2a8d 100755 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ sw.* # Local Netlify folder .netlify +static_website.tar.gz \ No newline at end of file diff --git a/bun.lockb b/bun.lockb index d245ca4..ca83343 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/scripts/download_latest_release.sh b/scripts/download_latest_release.sh new file mode 100644 index 0000000..49b2997 --- /dev/null +++ b/scripts/download_latest_release.sh @@ -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 diff --git a/scripts/extract_to_public_html.sh b/scripts/extract_to_public_html.sh new file mode 100644 index 0000000..6373da9 --- /dev/null +++ b/scripts/extract_to_public_html.sh @@ -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 \ No newline at end of file