[Feat]: Notification List UI Implementation #836
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
name: pull-request-update-or-push-tag | |
on: | |
pull_request: | |
push: | |
tags: | |
- "*" | |
env: | |
REGISTRY_IMAGE: aamdigital/ndb-server | |
jobs: | |
prepare-code-coverage: | |
runs-on: ubuntu-latest | |
env: | |
GIT_COMMIT_SHA: ${{ github.sha }} | |
GIT_BRANCH: ${{ github.head_ref }} | |
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }} | |
steps: | |
- name: Checkout repository files | |
uses: actions/checkout@v4 | |
- name: Install Code Climate Test Reporter | |
run: | | |
curl -Lo cc-test-reporter https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 | |
chmod +x ./cc-test-reporter | |
- name: Get time of commit | |
run: echo "GIT_COMMITTED_AT=$(git log -1 --pretty=format:%ct)" >> $GITHUB_ENV | |
- name: Run CC before-build | |
run: | | |
./cc-test-reporter before-build | |
test: | |
needs: | |
- prepare-code-coverage | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
os: | |
- ubuntu-latest | |
- [ self-hosted, Linux, ARM64 ] | |
exclude: | |
- platform: linux/arm64 | |
os: ubuntu-latest | |
- platform: linux/amd64 | |
os: [ self-hosted, Linux, ARM64 ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository files | |
uses: actions/checkout@v4 | |
- name: Prepare Platform | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Get time of commit | |
run: echo "TIME=$(git log -1 --pretty=format:%ct)" >> $GITHUB_ENV | |
- name: Create export directories | |
run: | | |
mkdir -p ./tmp/coverage | |
mkdir -p ./tmp/coverage/${{ env.PLATFORM_PAIR }} | |
- name: Run tests in Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: ./ | |
file: ./build/Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
outputs: type=local,dest=./tmp/coverage/${{ env.PLATFORM_PAIR }} | |
target: test-coverage | |
cache-from: type=gha | |
- name: Run tests with timezone | |
if: ${{ matrix.platform == 'linux/amd64' }} | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: ./ | |
file: ./build/Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
target: test | |
cache-from: type=gha | |
build-args: | | |
TZ=America/Detroit | |
- name: Upload coverage reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage-${{ env.PLATFORM_PAIR }} | |
path: ./tmp/coverage/* | |
if-no-files-found: error | |
retention-days: 1 | |
upload-code-coverage: | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
env: | |
GIT_COMMIT_SHA: ${{ github.sha }} | |
GIT_BRANCH: ${{ github.head_ref }} | |
CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_ID }} | |
steps: | |
- name: Checkout repository files | |
uses: actions/checkout@v4 | |
- name: Download coverage reports | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./tmp/coverage | |
pattern: coverage-* | |
merge-multiple: true | |
- name: Install Code Climate Test Reporter | |
run: | | |
curl -Lo cc-test-reporter https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 | |
chmod +x ./cc-test-reporter | |
- name: Run CC format-coverage | |
run: | | |
./cc-test-reporter format-coverage "./tmp/coverage/linux-amd64/coverage/lcov.info" -t lcov | |
- name: Run CC upload-coverage | |
run: | | |
./cc-test-reporter upload-coverage | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
os: | |
- ubuntu-latest | |
- [ self-hosted, Linux, ARM64 ] | |
exclude: | |
- platform: linux/arm64 | |
os: ubuntu-latest | |
- platform: linux/amd64 | |
os: [ self-hosted, Linux, ARM64 ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository files | |
uses: actions/checkout@v4 | |
- name: Extract tag (release) | |
if: ${{ github.event.ref != '' }} | |
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Extract tag (pull request) | |
if: ${{ github.event.ref == '' }} | |
run: echo "TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV | |
- name: Prepare Platform | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create export directories | |
run: | | |
mkdir -p ./tmp/build | |
mkdir -p ./tmp/build/${{ env.PLATFORM_PAIR }} | |
mkdir -p ./tmp/digests | |
- name: Build | |
id: build | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: ./ | |
file: ./build/Dockerfile | |
target: dist-build | |
outputs: type=local,dest=./tmp/build/${{ env.PLATFORM_PAIR }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=min | |
build-args: | | |
APP_VERSION=${{ env.TAG }} | |
env: | |
SOURCE_DATE_EPOCH: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Sentry CLI | |
run: | | |
npm install -g @sentry/cli | |
- name: Build Image and push by digest | |
id: build-image | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: ${{ matrix.platform }} | |
context: ./ | |
file: ./build/Dockerfile | |
target: app | |
labels: ${{ steps.meta.outputs.labels }} | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
cache-from: type=gha | |
cache-to: type=gha,mode=min | |
build-args: | | |
DIST_TYPE=local | |
LOCAL_DIST_PATH=./tmp/build/${{ env.PLATFORM_PAIR }}/dist | |
env: | |
SOURCE_DATE_EPOCH: 0 | |
- name: Export digest | |
run: | | |
digest="${{ steps.build-image.outputs.digest }}" | |
touch "./tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: ./tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload build archive | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ env.PLATFORM_PAIR }} | |
path: ./tmp/build/${{ env.PLATFORM_PAIR }} | |
if-no-files-found: error | |
retention-days: 1 | |
upload-sourcemaps: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
steps: | |
- name: Download builds | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./tmp/build | |
pattern: build-* | |
- name: Extract tag (release) | |
if: ${{ github.event.ref != '' }} | |
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Extract tag (pull request) | |
if: ${{ github.event.ref == '' }} | |
run: echo "TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Sentry CLI | |
run: | | |
npm install -g @sentry/cli | |
- name: Upload sourcemaps | |
run: | | |
ls -lsa ./tmp/build | |
ls -lsa ./tmp/build/build-linux-amd64 | |
# todo | |
sentry-cli sourcemaps upload --release="ndb-core@${{ env.TAG }}" ./tmp/build/build-linux-amd64/dist | |
sentry-cli sourcemaps upload --release="ndb-core@${{ env.TAG }}" ./tmp/build/build-linux-arm64/dist | |
merge: | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Create manifest list and push | |
working-directory: ./tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- merge | |
- upload-sourcemaps | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} | |
SENTRY_ORG: ${{ secrets.SENTRY_ORG }} | |
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} | |
steps: | |
- name: Extract tag (release) | |
if: ${{ github.event.ref != '' }} | |
run: echo "TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: Extract tag (pull request) | |
if: ${{ github.event.ref == '' }} | |
run: echo "TAG=pr-${{ github.event.number }}" >> $GITHUB_ENV | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install Sentry CLI | |
run: | | |
npm install -g @sentry/cli | |
- name: Create Release | |
if: ${{ github.event.ref != '' }} # only send "official" releases to Sentry | |
run: | | |
sentry-cli releases new "ndb-core@${{ env.TAG }}" | |
deploy: | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
steps: | |
- name: Deploy updated image | |
if: ${{ github.event.ref == '' }} | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_KEY }} | |
script: | | |
cd /var/docker/pr-${{ github.event.number }} | |
docker compose pull | |
docker compose up -d |