Skip to content

Update git build permissions. #77

Update git build permissions.

Update git build permissions. #77

name: Build and Deploy
on:
push:
branches:
- main
- dev
- pipeline
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build_image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
- name: Clean npm cache
run: npm cache clean --force
- name: Install dependencies and update lock file if necessary
run: |
if [ -f package-lock.json ]; then
npm ci || npm install
else
npm install
fi
- 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 Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"NEXT_PUBLIC_SERVER_URL=${{ github.ref == 'refs/heads/main' && secrets.NEXT_PUBLIC_SERVER_URL_PROD || secrets.NEXT_PUBLIC_SERVER_URL_DEV }}"
outputs:
image_tag: ${{ steps.meta.outputs.tags }}
deploy:
needs: build_image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Authenticate and set context for OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
namespace: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_NAMESPACE || secrets.OPENSHIFT_DEV_NAMESPACE }}
openshift_token: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_TOKEN || secrets.OPENSHIFT_DEV_TOKEN }}
insecure_skip_tls_verify: true
- name: Run Helm
run: |
helm upgrade --install brms-frontend ./helm --set image.tag=${{ needs.build_image.outputs.image_tag }}