-
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.
- Loading branch information
Showing
3 changed files
with
130 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,53 @@ | ||
name: Continuous integration | ||
|
||
on: | ||
push: | ||
branches: [develop, serenity, euphoria] | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set environment variable | ||
run: | | ||
SHORT_SHA_COMMIT=$(git rev-parse --short HEAD) | ||
echo CONTAINER_RELEASE_IMAGE=ghcr.io/aura-nw/long-campaign-fe:${GITHUB_REF_NAME}_${SHORT_SHA_COMMIT} >> $GITHUB_ENV | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ env.CONTAINER_RELEASE_IMAGE }} | ||
update-manifest: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set environment variable | ||
run: | | ||
SHORT_SHA_COMMIT=$(git rev-parse --short HEAD) | ||
echo CONTAINER_RELEASE_IMAGE=ghcr.io/aura-nw/long-campaign-fe:${GITHUB_REF_NAME}_${SHORT_SHA_COMMIT} >> $GITHUB_ENV | ||
echo REPO_MANIFEST_NAME=gitops >> $GITHUB_ENV | ||
echo REPO_MANIFEST_URL=github.com/aura-nw/gitops.git >> $GITHUB_ENV | ||
echo REPO_MANIFEST_BRANCH=main >> $GITHUB_ENV | ||
echo REPO_MANIFEST_ENV_DEV=./clusters/k8s-dev/long-campaign >> $GITHUB_ENV | ||
echo REPO_MANIFEST_ENV_STAGING=./clusters/k8s-testnet-serenity/long-campaign >> $GITHUB_ENV | ||
echo REPO_MANIFEST_ENV_EUPHORIA=./clusters/k8s-testnet-euphoria/long-campaign >> $GITHUB_ENV | ||
echo REPO_MANIFEST_ENV_SERENITY=./clusters/k8s-testnet-serenity/long-campaign >> $GITHUB_ENV | ||
echo REPO_MANIFEST_TAG_IMAGE=image_long_campaign_fe >> $GITHUB_ENV | ||
- name: Update manifest | ||
env: | ||
PERSONAL_ACCESS_TOKEN: ${{ secrets.REGISTRY_PASSWORD }} | ||
run: | | ||
chmod 777 -R ./ci | ||
./ci/updateManifest.sh |
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,35 @@ | ||
# Build BASE | ||
FROM node:18-alpine as BASE | ||
WORKDIR /app | ||
|
||
COPY package.json yarn.lock ./ | ||
RUN yarn install | ||
|
||
# Build Image | ||
FROM node:18-alpine AS BUILD | ||
WORKDIR /app | ||
|
||
RUN apk add --no-cache curl | ||
RUN curl -sf https://gobinaries.com/tj/node-prune | sh -s -- -b /usr/local/bin | ||
|
||
COPY --from=BASE /app/node_modules ./node_modules | ||
COPY . . | ||
RUN yarn build | ||
RUN cd .next/standalone | ||
RUN node-prune | ||
|
||
# Build production | ||
FROM node:18-alpine AS PRODUCTION | ||
ENV NODE_ENV production | ||
WORKDIR /app | ||
|
||
# COPY --from=BUILD /app/.env.example ./.env | ||
COPY --from=BUILD /app/public ./public | ||
COPY --from=BUILD /app/next.config.js ./ | ||
COPY --from=BUILD /app/.next/standalone ./ | ||
COPY --from=BUILD /app/.next/static ./.next/static | ||
|
||
RUN mkdir -p /app/public/social-images/ | ||
|
||
EXPOSE 3000 | ||
CMD ["node", "server.js"] |
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,42 @@ | ||
#!/bin/sh | ||
set -xe | ||
|
||
# clone repo manifest | ||
git clone "https://${PERSONAL_ACCESS_TOKEN}@${REPO_MANIFEST_URL}" | ||
cd ./${REPO_MANIFEST_NAME} | ||
git checkout ${REPO_MANIFEST_BRANCH} && git pull | ||
|
||
if [ ${GITHUB_REF_NAME} = "main" ] | ||
then | ||
echo 'This is main branch' | ||
cd ${REPO_MANIFEST_ENV_MAIN} | ||
elif [ ${GITHUB_REF_NAME} = "develop" ] | ||
then | ||
echo 'This is dev branch' | ||
cd ${REPO_MANIFEST_ENV_DEV} | ||
elif [ ${GITHUB_REF_NAME} = "staging" ] | ||
then | ||
echo 'This is staging branch' | ||
cd ${REPO_MANIFEST_ENV_STAGING} | ||
elif [ ${GITHUB_REF_NAME} = "euphoria" ] | ||
then | ||
echo 'This is euphoria branch' | ||
cd ${REPO_MANIFEST_ENV_EUPHORIA} | ||
elif [ ${GITHUB_REF_NAME} = "serenity" ] | ||
then | ||
echo 'This is serenity branch' | ||
cd ${REPO_MANIFEST_ENV_SERENITY} | ||
else | ||
exit | ||
fi | ||
|
||
# kustomize | ||
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash | ||
./kustomize edit set image ${REPO_MANIFEST_TAG_IMAGE}=${CONTAINER_RELEASE_IMAGE} | ||
rm kustomize | ||
|
||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR}@github.com" | ||
git add . | ||
git commit -m "Update image to ${CONTAINER_RELEASE_IMAGE}" | ||
git push |