Skip to content

Commit 88c0baf

Browse files
committed
ci: add stuff for argocd
Signed-off-by: Jonathan Basniak <740416+gm112@users.noreply.github.com> ci: add stuff for argocd Signed-off-by: Jonathan Basniak <740416+gm112@users.noreply.github.com> ci: fix string case sensitivity on ghcr.io ci: fix string case sensitivity on ghcr.io ci: fix string case sensitivity on ghcr.io
1 parent f23d203 commit 88c0baf

3 files changed

Lines changed: 134 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: Override image tag (defaults to short SHA)
10+
required: false
11+
default: ""
12+
api_url:
13+
description: Browser-facing API URL baked into the build (REACT_ZFGBB_API_URL)
14+
required: false
15+
default: "https://api.bluedreamers.com/zfgbb"
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
env:
22+
IMAGE_NAME: zfgbb-react
23+
24+
jobs:
25+
build-and-push:
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 30
28+
outputs:
29+
tag: ${{ steps.meta.outputs.tag }}
30+
steps:
31+
- uses: actions/checkout@v6
32+
33+
- name: Compute lowercase image ref + tag
34+
id: meta
35+
run: |
36+
set -euo pipefail
37+
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/${IMAGE_NAME}" >> "$GITHUB_ENV"
38+
if [[ -n "${{ inputs.tag }}" ]]; then
39+
tag="${{ inputs.tag }}"
40+
else
41+
tag="${GITHUB_SHA::12}"
42+
fi
43+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
44+
45+
- uses: docker/setup-buildx-action@v4
46+
47+
- uses: docker/login-action@v4
48+
with:
49+
registry: ghcr.io
50+
username: ${{ github.actor }}
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Build and push
54+
uses: docker/build-push-action@v7
55+
with:
56+
context: .
57+
target: app
58+
push: true
59+
provenance: false
60+
build-args: |
61+
REACT_ZFGBB_API_URL=${{ inputs.api_url || 'https://api.bluedreamers.com/zfgbb' }}
62+
tags: |
63+
${{ env.IMAGE }}:${{ steps.meta.outputs.tag }}
64+
${{ env.IMAGE }}:latest
65+
cache-from: type=registry,ref=${{ env.IMAGE }}:cache
66+
cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max
67+
68+
bump-argo:
69+
needs: build-and-push
70+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout argocd repo
74+
uses: actions/checkout@v6
75+
with:
76+
repository: ZeldaFanGameCentral/argocd.zfgc.com
77+
token: ${{ secrets.PR_BUMP_TOKEN }}
78+
path: argocd
79+
80+
- name: Bump image.tag in charts/zfgbb-react/values.yaml
81+
id: bump
82+
env:
83+
NEW_TAG: ${{ needs.build-and-push.outputs.tag }}
84+
run: |
85+
set -euo pipefail
86+
cd argocd
87+
file=charts/zfgbb-react/values.yaml
88+
old_tag=$(awk '/^ tag:/{print $2; exit}' "$file" | tr -d '"')
89+
if [[ "$old_tag" == "$NEW_TAG" ]]; then
90+
echo "tag already $NEW_TAG; nothing to bump"
91+
echo "changed=false" >> "$GITHUB_OUTPUT"
92+
exit 0
93+
fi
94+
sed -i "0,/^ tag: .*/s|| tag: $NEW_TAG|" "$file"
95+
echo "old_tag=$old_tag" >> "$GITHUB_OUTPUT"
96+
echo "changed=true" >> "$GITHUB_OUTPUT"
97+
98+
- name: Open PR
99+
if: steps.bump.outputs.changed == 'true'
100+
env:
101+
GH_TOKEN: ${{ secrets.PR_BUMP_TOKEN }}
102+
NEW_TAG: ${{ needs.build-and-push.outputs.tag }}
103+
OLD_TAG: ${{ steps.bump.outputs.old_tag }}
104+
run: |
105+
set -euo pipefail
106+
cd argocd
107+
branch="bump/zfgbb-react-$NEW_TAG"
108+
git config user.name 'zfgbb-react-release-bot'
109+
git config user.email 'zfgbb-react-release-bot@users.noreply.github.com'
110+
git checkout -b "$branch"
111+
git add charts/zfgbb-react/values.yaml
112+
msg=$(printf 'Bump zfgbb-react image to %s\n\nFrom: %s\nTo: %s\n' "$NEW_TAG" "$OLD_TAG" "$NEW_TAG")
113+
git commit -m "$msg"
114+
git push -u origin "$branch"
115+
gh pr create \
116+
--base main \
117+
--head "$branch" \
118+
--title "Bump zfgbb-react image to $NEW_TAG" \
119+
--body "Automated bump from \`$OLD_TAG\` to \`$NEW_TAG\` in \`charts/zfgbb-react/values.yaml\`. Built from $GITHUB_REPOSITORY@$GITHUB_SHA."

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
FROM node:24-alpine AS development-dependencies-env
2+
RUN corepack enable
23
COPY . /app
34
WORKDIR /app
4-
RUN yarn install --frozen-lockfile
5+
RUN yarn install --immutable
56

67
FROM development-dependencies-env AS production-dependencies-env
7-
COPY ./package.json package-lock.json /app/
88
WORKDIR /app
99
RUN yarn prepare:prod
1010

1111
FROM node:24-alpine AS build-env
12+
RUN corepack enable
13+
ARG REACT_ZFGBB_API_URL=https://api.bluedreamers.com/zfgbb
14+
ARG REACT_ZFGBB_API_URL_INTERNAL=http://zfgbb.zfgbb.svc.cluster.local:8080/zfgbb
15+
ENV REACT_ZFGBB_API_URL=$REACT_ZFGBB_API_URL
16+
ENV REACT_ZFGBB_API_URL_INTERNAL=$REACT_ZFGBB_API_URL_INTERNAL
1217
COPY . /app/
1318
COPY --from=development-dependencies-env /app/node_modules /app/node_modules
1419
WORKDIR /app
1520
RUN yarn build
1621

17-
FROM node:24-alpine as app
22+
FROM node:24-alpine AS app
23+
RUN corepack enable
1824
COPY ./package.json yarn.lock /app/
1925
COPY --from=production-dependencies-env /app/node_modules /app/node_modules
2026
COPY --from=build-env /app/build /app/build

src/pages/healthz.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export function loader() {
2+
return new Response('{"status":"ok"}', {
3+
status: 200,
4+
headers: { "content-type": "application/json" },
5+
});
6+
}

0 commit comments

Comments
 (0)