Merge pull request #503 from NillionNetwork/feat/validate-semver #52
This file contains hidden or 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: nilcc-api docker | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: read # Required for checkout | |
| defaults: | |
| run: | |
| working-directory: ./nilcc-api | |
| jobs: | |
| deliver: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.set-outputs.outputs.image_tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: "arn:aws:iam::054037142884:role/nilcc-api-github" | |
| aws-region: "us-east-1" | |
| - uses: aws-actions/amazon-ecr-login@v2 | |
| id: login-ecr | |
| with: | |
| registry-type: public | |
| - name: Build and push images | |
| id: build-push | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REGISTRY_ALIAS: k5d9x2g2 | |
| ECR_REPOSITORY: nilcc-api | |
| IMAGE_TAG_SHA: ${{ github.sha }} | |
| run: | | |
| ECR_REGISTRY_URL="${ECR_REGISTRY}/${ECR_REGISTRY_ALIAS}/${ECR_REPOSITORY}" | |
| # Always tag with commit sha | |
| TAGS="-t ${ECR_REGISTRY_URL}:${IMAGE_TAG_SHA}" | |
| DEPLOY_TAG="${IMAGE_TAG_SHA}" | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| # On manual trigger, use version from package.json | |
| IMAGE_TAG_VERSION=$(cat package.json | jq -r .version) | |
| TAGS="$TAGS -t ${ECR_REGISTRY_URL}:${IMAGE_TAG_VERSION}" | |
| DEPLOY_TAG="${IMAGE_TAG_VERSION}" | |
| fi | |
| docker build \ | |
| --push \ | |
| -f Dockerfile \ | |
| $TAGS \ | |
| . | |
| echo "Used tags: $TAGS" >> $GITHUB_STEP_SUMMARY | |
| echo "deploy_tag=${DEPLOY_TAG}" >> $GITHUB_OUTPUT | |
| - name: Set outputs | |
| id: set-outputs | |
| run: echo "image_tag=${{ steps.build-push.outputs.deploy_tag }}" >> $GITHUB_OUTPUT |