fix build/push action provenance setting #92
This file contains 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: warp-protocol-api | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
- test | |
- beta | |
paths: | |
- indexers/warp-protocol/src/** | |
- apps/warp-protocol-api/src/** | |
- indexers/warp-protocol/Dockerfile | |
- apps/warp-protocol-api/Dockerfile | |
- .github/workflows/warp-protocol-api.yml | |
pull_request: | |
branches: | |
- main | |
- test | |
- beta | |
paths: | |
- indexers/warp-protocol/src/** | |
- apps/warp-protocol-api/src/** | |
- indexers/warp-protocol/Dockerfile | |
- apps/warp-protocol-api/Dockerfile | |
- .github/workflows/warp-protocol-api.yml | |
env: | |
AWS_REGION: "ap-northeast-2" | |
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_ACCESS_KEY }}" | |
AWS_SECRET_ACCESS_KEY: "${{ secrets.AWS_SECRET_KEY }}" | |
MAIN_BRANCH: "main" | |
IDX_DOCKERFILE: "indexers/warp-protocol/Dockerfile" | |
IDX_CONTEXT_PATH: "." | |
IDX_ECR_REPO: "warp-protocol-idx" | |
API_DOCKERFILE: "apps/warp-protocol-api/Dockerfile" | |
API_CONTEXT_PATH: "." | |
API_ECR_REPO: "warp-protocol-api" | |
TERRAFORM_REPO: "terra-money/tf-apps-warp" | |
jobs: | |
idx-integration: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Test Build | |
uses: docker/build-push-action@v3 | |
with: | |
push: false | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
file: ${{ env.IDX_DOCKERFILE }} | |
context: ${{ env.IDX_CONTEXT_PATH }} | |
outputs: | |
main_branch_ref: ${{ format('refs/heads/{0}', env.MAIN_BRANCH) }} | |
api-integration: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Test Build | |
uses: docker/build-push-action@v3 | |
with: | |
push: false | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
file: ${{ env.API_DOCKERFILE }} | |
context: ${{ env.API_CONTEXT_PATH }} | |
outputs: | |
main_branch_ref: ${{ format('refs/heads/{0}', env.MAIN_BRANCH) }} | |
idx-delivery: | |
runs-on: ubuntu-latest | |
needs: [idx-integration] | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Set tags | |
run: | | |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then | |
echo "DOCKER_IMAGE_TAG=phoenix-1" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/test" ]; then | |
echo "DOCKER_IMAGE_TAG=pisco-1" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then | |
echo "DOCKER_IMAGE_TAG=beta" >> $GITHUB_ENV | |
else | |
echo "DOCKER_IMAGE_TAG=latest" >> $GITHUB_ENV | |
fi | |
- name: Build, tag, and push docker image to AWS ECR | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
file: ${{ env.IDX_DOCKERFILE }} | |
context: ${{ env.IDX_CONTEXT_PATH }} | |
tags: | | |
${{ steps.login-ecr.outputs.registry }}/${{ env.IDX_ECR_REPO }}:${{ env.DOCKER_IMAGE_TAG }} | |
api-delivery: | |
runs-on: ubuntu-latest | |
needs: [api-integration] | |
if: github.event_name != 'pull_request' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Set tags | |
run: | | |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then | |
echo "DOCKER_IMAGE_TAG=phoenix-1" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/test" ]; then | |
echo "DOCKER_IMAGE_TAG=pisco-1" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then | |
echo "DOCKER_IMAGE_TAG=beta" >> $GITHUB_ENV | |
else | |
echo "DOCKER_IMAGE_TAG=latest" >> $GITHUB_ENV | |
fi | |
- name: Build, tag, and push docker image to AWS ECR | |
uses: docker/build-push-action@v3 | |
with: | |
push: true | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache | |
file: ${{ env.API_DOCKERFILE }} | |
context: ${{ env.API_CONTEXT_PATH }} | |
provenance: false | |
tags: | | |
${{ steps.login-ecr.outputs.registry }}/${{ env.API_ECR_REPO }}:${{ env.DOCKER_IMAGE_TAG }} | |
dispatch: | |
runs-on: ubuntu-latest | |
needs: [idx-delivery, api-delivery] | |
steps: | |
- name: Set Remote ref | |
run: | | |
if [ ${GITHUB_REF} == "refs/heads/main" ]; then | |
echo "TF_GITHUB_REF=phoenix-1" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/beta" ]; then | |
echo "TF_GITHUB_REF=phoenix-1-beta" >> $GITHUB_ENV | |
elif [ ${GITHUB_REF} == "refs/heads/test" ]; then | |
echo "TF_GITHUB_REF=pisco-1" >> $GITHUB_ENV | |
fi | |
- name: Invoke Terraform Workflow | |
uses: aurelien-baudet/workflow-dispatch@v2 | |
with: | |
repo: ${{ env.TERRAFORM_REPO }} | |
ref: ${{ env.TF_GITHUB_REF }} | |
workflow: Terraform | |
token: ${{ secrets.TFL_GITHUB_TOKEN }} |