Merge pull request #503 from AppQuality/update-token-acceptance-logic #3108
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
| on: | |
| push: | |
| branches: | |
| - "*" | |
| workflow_dispatch: | |
| name: Push to Amazon ECR | |
| env: | |
| ECR_REPOSITORY: appquality-api-express | |
| jobs: | |
| push-to-ecr: | |
| name: Push Image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Extract branch name | |
| shell: bash | |
| run: | | |
| BRANCH=$(echo ${GITHUB_REF#refs/heads/}) | |
| if [ "$BRANCH" = "main" ]; then | |
| TAG="latest" | |
| else | |
| TAG="$BRANCH" | |
| fi | |
| echo "##[set-output name=tag;]$TAG" | |
| id: extract_branch | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: eu-west-1 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Build, tag, and push image to Amazon ECR | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | |
| IMAGE_TAG: ${{ steps.extract_branch.outputs.tag }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| DOCKER_BUILDKIT=1 docker build --build-arg NPM_TOKEN=$NPM_TOKEN -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |