From 9b7f3b79923a10d92fba78a875ab8f66d6dac4d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chase=20=E6=9D=8E?= Date: Sun, 14 Jan 2024 19:40:45 -0600 Subject: [PATCH] Adding GitHub workflows to generate container images (#235) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding GitHub workflows to generate container images for app * Updating Flourish references to SparkHacks in README. --------- Co-authored-by: Chase 李 --- .github/workflows/container-build-merge.yml | 52 +++++++++++++++++++++ .github/workflows/container-build-pr.yml | 44 +++++++++++++++++ README.md | 6 +-- 3 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/container-build-merge.yml create mode 100644 .github/workflows/container-build-pr.yml diff --git a/.github/workflows/container-build-merge.yml b/.github/workflows/container-build-merge.yml new file mode 100644 index 0000000..a9ead24 --- /dev/null +++ b/.github/workflows/container-build-merge.yml @@ -0,0 +1,52 @@ +--- +name: Container Build Merge + +on: + push: + branches: + - 'main' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout Repository 🛎️ + uses: actions/checkout@v4 + - name: Set up Docker Buildx 🐳 + uses: docker/setup-buildx-action@v3 + - name: Login to Container Registry 🪪 + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for container 📤 + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Use Node 20.x 🔧 + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + - name: Install App Build Dependencies 📃 + run: | + npm ci + - name: Build App 🛠️ + run: | + npm run build + - name: Build and push container 🚢 + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/container-build-pr.yml b/.github/workflows/container-build-pr.yml new file mode 100644 index 0000000..66bcba2 --- /dev/null +++ b/.github/workflows/container-build-pr.yml @@ -0,0 +1,44 @@ +--- +name: Container Build PR + +on: + pull_request: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout Repository 🛎️ + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Extract metadata (tags, labels) for container 📤 + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Use Node 20.x 🔧 + uses: actions/setup-node@v4 + with: + node-version: "20.x" + cache: "npm" + - name: Install App Build Dependencies 📃 + run: | + npm ci + - name: Build App 🛠️ + run: | + npm run build + - name: Build container 📦 + uses: docker/build-push-action@v5 + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/README.md b/README.md index 0ac84f4..75773bc 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ You will need to install the following programs - [Node.js](https://nodejs.org/en/) (Use the LTS release) Once you have installed the above, open your terminal and execute the following commands -- `git clone git@github.com:acm-uic/flourish-2023.git` (You may want to clone this to your Downloads or other folder) -- `cd flourish-2023` +- `git clone git@github.com:acm-uic/sparkhacks-2023.git` (You may want to clone this to your Downloads or other folder) +- `cd sparkhacks-2023` - `npm install` Once you have done these steps, you are good to go! @@ -23,7 +23,7 @@ Running the website locally is as simple as `npm start`! ## Making a contribution -Follow the guide in the [wiki](https://github.com/acm-uic/flourish-2023/wiki/Guide-to-Contribution) +Follow the guide in the [wiki](https://github.com/acm-uic/sparkhacks-2023/wiki/Guide-to-Contribution) ### Helper scripts