|
| 1 | +name: ci-check-ns-api-version |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - "nym-node-status-api/**" |
| 7 | + |
| 8 | +env: |
| 9 | + WORKING_DIRECTORY: "nym-node-status-api/nym-node-status-api" |
| 10 | + |
| 11 | +jobs: |
| 12 | + check-if-tag-exists: |
| 13 | + runs-on: arc-ubuntu-22.04-dind |
| 14 | + steps: |
| 15 | + - name: Checkout repo |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Get version from cargo.toml |
| 19 | + |
| 20 | + id: get_version |
| 21 | + with: |
| 22 | + cmd: yq -oy '.package.version' ${{ env.WORKING_DIRECTORY }}/Cargo.toml |
| 23 | + |
| 24 | + - name: Check if git tag exists |
| 25 | + uses: actions/checkout@v4 |
| 26 | + - run: | |
| 27 | + TAG=${{ env.WORKING_DIRECTORY }}-${{ steps.get_version.outputs.result }} |
| 28 | + if [[ -z "$TAG" ]]; then |
| 29 | + echo "Tag is empty" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | + if git ls-remote --tags origin | grep -q "refs/tags/$TAG$" ; then |
| 33 | + echo "Tag '$TAG' ALREADY EXISTS on the remote" |
| 34 | + # TODO uncomment after bumping NS API version |
| 35 | + # exit 1 |
| 36 | + else |
| 37 | + echo "Tag '$TAG' does not exist on the remote" |
| 38 | + fi |
| 39 | + - name: Check if harbor tag exists |
| 40 | + run: | |
| 41 | + TAG=${{ steps.get_version.outputs.result }} |
| 42 | + registry=https://harbor.nymte.ch |
| 43 | + repo_name=nym/node-status-api |
| 44 | + if [[ -z $TAG ]]; then |
| 45 | + echo "Tag is empty" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + curl -su "${{ secrets.HARBOR_ROBOT_USERNAME }}":"${{ secrets.HARBOR_ROBOT_SECRET }}" "$registry/v2/$repo_name/tags/list" | jq |
| 49 | + curl -su ${{ secrets.HARBOR_ROBOT_USERNAME }}:${{ secrets.HARBOR_ROBOT_SECRET }} "$registry/v2/$repo_name/tags/list" | jq -e --arg search $TAG '.tags | index($search)' > /dev/null |
| 50 | + result=$? |
| 51 | + if [ "${result}" -eq 0 ]; then |
| 52 | + echo "Version '$TAG' defined in Cargo.toml already exists as tag in harbor repo" |
| 53 | + # TODO uncomment after bumping NS API version |
| 54 | + # exit 1 |
| 55 | + else |
| 56 | + echo "Version '$TAG' doesn't exist on the remote" |
| 57 | + fi |
0 commit comments