Skip to content

Commit

Permalink
Merge branch 'master' into FD-618-health-check
Browse files Browse the repository at this point in the history
  • Loading branch information
soson authored Feb 28, 2024
2 parents 20bb1dd + acf1c69 commit 283feb4
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 75 deletions.
68 changes: 38 additions & 30 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ name: Docker
on:
workflow_dispatch:
push:
# Publish `master` as Docker `latest` image.
# Publish `master` and `stable` as Docker `latest` image.
branches:
- master
- 'master'
- '[0-9]+.X-stable'

# Publish `v1.2.3` tags as releases.
tags:
- v*
- 'v*'
- 'v[0-9]+.[0-9]+.[0-9]-stable'

env:
IMAGE_NAME: frinx/frinx-inventory-server
Expand All @@ -26,38 +28,44 @@ jobs:
with:
fetch-depth: 0

- name: Set tag and hive token for latest image
if: github.ref_type == 'branch' && startsWith(github.ref, 'refs/heads/master')
run: |
echo "IMAGE_TAG=$(echo 'latest')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_MASTER_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for stable-latest image
if: github.ref_type == 'branch' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo 'stable-latest')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for stable-release image
if: github.ref_type == 'tag' && endsWith(github.ref, '-stable')
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^v-//' | sed -e 's/-stable//')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_RELEASE_TOKEN }}" >> "$GITHUB_ENV"
- name: Set tag and hive token for release image
if: ${{ github.ref_type == 'tag' && !endsWith(github.ref, '-stable') }}
run: |
echo "IMAGE_TAG=$(echo $GITHUB_REF | cut -d / -f 3 | sed -e 's/^v-//')" >> "$GITHUB_ENV"
echo "HIVE_TOKEN=${{ secrets.HIVE_MASTER_RELEASE_TOKEN }}" >> "$GITHUB_ENV"
- name: Build image
run: docker build --build-arg git_commit=$(git rev-parse HEAD) . --file Dockerfile --tag $IMAGE_NAME

- name: Log into docker hub
run: echo "${{ secrets.DOCKER_HUB_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin

- name: Push image
run: docker push $IMAGE_NAME:${IMAGE_TAG}

- name: Hive publish
env:
SCHEMA_PATH: "src/schema/api.graphql"
run: |
IMAGE_ID=$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
# Add latest tag if we are on master and github.ref points to a tag
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
MASTER=$(git show-ref --hash origin/master)
echo "master: $MASTER"
HEAD=$(git rev-parse HEAD)
echo "head: $HEAD"
echo "github.ref ${{ github.ref }}"
if [[ $MASTER == $HEAD ]]; then
VERSION=latest
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
fi
fi
curl -sSL https://graphql-hive.com/install.sh | sh
hive schema:publish ${{ env.SCHEMA_PATH }} \
--registry.accessToken ${HIVE_TOKEN} \
--github
22 changes: 0 additions & 22 deletions .github/workflows/hive-cd.yml

This file was deleted.

36 changes: 31 additions & 5 deletions .github/workflows/hive-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ name: Hive Check

on:
pull_request:
branches: [master]
branches:
- 'master'
- '[0-9]+.X-stable'

tags:
- 'v*'
- 'v[0-9]+.[0-9]+.[0-9]-stable'

jobs:
hive-check:
Expand All @@ -11,12 +17,32 @@ jobs:
steps:
- name: checkout
uses: actions/checkout@v3

- name: Stable token
if: github.ref_type == 'branch' && endsWith(github.base_ref, '-stable')
run: |
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Master token
if: github.ref_type == 'branch' && github.base_ref == 'master'
run: |
echo "HIVE_TOKEN=${{ secrets.HIVE_MASTER_LATEST_TOKEN }}" >> "$GITHUB_ENV"
- name: Stable release token
if: github.ref_type == 'tag' && endsWith(github.ref, '-stable')
run: |
echo "HIVE_TOKEN=${{ secrets.HIVE_STABLE_RELEASE_TOKEN }}" >> "$GITHUB_ENV"
- name: Master release token
if: ${{ github.ref_type == 'tag' && !endsWith(github.ref, '-stable') }}
run: |
echo "HIVE_TOKEN=${ secrets.HIVE_MASTER_RELEASE_TOKEN }" >> "$GITHUB_ENV"
- name: schema check
env:
HIVE_TOKEN: ${{ secrets.HIVE_TOKEN_DEVELOPMENT }}
SCHEMA_PATH: "src/schema/api.graphql"
run: |
curl -sSL https://graphql-hive.com/install.sh | sh
hive schema:check "${{ env.SCHEMA_PATH }}" \
--registry.accessToken ${{ env.HIVE_TOKEN }} \
--github
hive schema:check ${{ env.SCHEMA_PATH }} \
--registry.accessToken ${HIVE_TOKEN} \
--github
18 changes: 6 additions & 12 deletions src/__generated__/topology-discovery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/external-api/topology-discovery-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ const SYNCE_TOPOLOGY = gql`
cursor
node {
...SynceInterfaceParts
details {
synce_enabled
rx_quality_level
qualified_for_use
not_qualified_due_to
not_selected_due_to
}
}
}
}
Expand Down
Loading

0 comments on commit 283feb4

Please sign in to comment.