name: Reusable Publish Docker Image Workflow on: workflow_call: inputs: service_name: required: true type: string package_path: required: true type: string workspace_name: required: true type: string secrets: DOCKER_USERNAME: required: true DOCKER_PASSWORD: required: true AWS_ACCESS_KEY_ID: required: true AWS_SECRET_ACCESS_KEY: required: true jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: '3.11' - name: Cache build id: cache-build uses: actions/cache@v3 with: path: | packages/**/dist key: ${{ runner.os }}-${{ inputs.service_name }}-build-${{ github.sha }} - name: Set up Node uses: actions/setup-node@v3 with: registry-url: 'https://registry.npmjs.org' node-version-file: '.nvmrc' - name: Install dependencies run: yarn install --immutable - name: Build if: steps.cache-build.outputs.cache-hit != 'true' run: yarn build - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v3 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-east-1 - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v2 - name: Set up QEMU uses: docker/setup-qemu-action@master with: platforms: all - name: Set up Docker Buildx id: buildx uses: docker/setup-buildx-action@master - name: Publish Docker image uses: docker/build-push-action@v4 with: builder: ${{ steps.buildx.outputs.name }} context: . file: ${{ inputs.package_path }}/Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: | standardnotes/${{ inputs.service_name }}:latest standardnotes/${{ inputs.service_name }}:${{ github.sha }} ${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:${{ github.sha }} ${{ steps.login-ecr.outputs.registry }}/${{ inputs.service_name }}:latest