Skip to content
Merged
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
109 changes: 0 additions & 109 deletions .github/workflows/build-deploy-prod.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-deploy-staging.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Deploy Staging
name: Build and Deploy Staging

on:
workflow_dispatch:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/deploy-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy Production

on:
workflow_dispatch:
inputs:
target:
required: true
description: New tag (e.g., v1.2.3)

env:
GITOPS_REPO: esc-chula/tech-website-gitops
PROD_DEPLOYMENT_PATH: overlays/prod/kustomization.yaml
IMAGE_NAME: ghcr.io/${{ github.repository }}

jobs:
deploy-production:
name: Deploy Production
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Pull Image To Check Existence
id: pull-image
run: |
IMAGE_TAG="${{ github.event.inputs.target }}"
IMAGE_NAME="${{ env.IMAGE_NAME }}"
docker pull "${IMAGE_NAME}:${IMAGE_TAG}" || exit 0

- name: Process Release Version
id: version
run: |
RAW_TAG="${{ github.event.inputs.target }}"
PROCESSED_TAG="${RAW_TAG#v}"
echo "VERSION=$PROCESSED_TAG" >> "$GITHUB_OUTPUT"

- name: Checkout GitOps Repository
uses: actions/checkout@v4
with:
repository: ${{ env.GITOPS_REPO }}
token: ${{ secrets.GITOPS_TOKEN }}
path: gitops

- name: Update Image Tag in GitOps Repository
env:
IMAGE_TAG: ${{ steps.version.outputs.VERSION }}
run: |
DEPLOYMENT_PATH="gitops/${{ env.PROD_DEPLOYMENT_PATH }}"

# Update the `newTag` field inside `images` list
yq -i '(.images[] | select(.name == "ghcr.io/esc-chula/tech-website")).newTag = "${{ env.IMAGE_TAG }}"' "$DEPLOYMENT_PATH"

- name: Commit and Push Changes to GitOps Repo
run: |
cd gitops
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "build(deploy): Update production deployment for ${{ steps.version.outputs.VERSION }}"
git push
49 changes: 48 additions & 1 deletion .github/workflows/release-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release Production
name: Build and Release Production

on:
workflow_dispatch:
Expand All @@ -7,7 +7,54 @@ on:
required: true
description: New tag (e.g., v1.2.3)

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}

jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set Image Tags
id: set-tag
run: |
RAW_TAG="${{ github.event.inputs.target }}"

if [[ ! "$RAW_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid tag format. Please use vX.Y.Z format."
exit 1
fi

echo "IMAGE_TAG=${RAW_TAG#v}" >> "$GITHUB_ENV"
echo "IMAGE_NAME=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v3
with:
file: Dockerfile
push: true
tags: ${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}
cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max

release_commit:
name: Release Commit
runs-on: ubuntu-latest
Expand Down