diff --git a/.github/workflows/ECRPush.yml b/.github/workflows/ECRPush.yml new file mode 100644 index 0000000..e3bc076 --- /dev/null +++ b/.github/workflows/ECRPush.yml @@ -0,0 +1,55 @@ +name: ECRPush +run-name: Deploy version ${{ inputs.version }} to ${{ inputs.environment }} + +on: + workflow_dispatch: + inputs: + version: + type: string + description: "Version of package to deploy" + required: true + environment: + type: environment + description: "Target environment" + required: true + +permissions: + id-token: write + contents: read + packages: read + +jobs: + pull-push: + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + concurrency: + group: ${{ github.workflow }}-${{ inputs.version }}-${{ inputs.environment }}-pull-push + cancel-in-progress: true + steps: + - name: Log in to GitHub Container Registry + uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4 + with: + role-to-assume: ${{ vars.AWS_ROLE_ARN }} + role-session-name: gha_build_${{ github.repository_id }}_${{ github.run_id }} + aws-region: ${{ vars.AWS_REGION }} + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@183a1442edf41672e66566b7fc560e297a290896 # v2 + - name: Pull from GHCR, tag for ECR, and push + run: | + SRC="ghcr.io/${{ github.repository }}:${{ inputs.version }}" + DST="${{ vars.MULTI_BUY_SERVICE_ECR_URL }}:${{ inputs.version }}" + + echo "Pulling $SRC" + docker pull "$SRC" + + echo "Tagging $SRC -> $DST" + docker tag "$SRC" "$DST" + + echo "Pushing $DST" + docker push "$DST" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9702207..efd2b31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -176,4 +176,4 @@ jobs: file: Dockerfile target: runner push: true - tags: ghcr.io/${{ github.repository }}/multi_buy_service:${{ github.ref_name }} + tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}