Skip to content

Split publish and deploy workflows #967

Split publish and deploy workflows

Split publish and deploy workflows #967

Workflow file for this run

# This action acts as a signal dispatcher that fires whenever the release process has
# successfully completed. The listening workflow within the infra-k8s repository has
# a corresponding event handler to generate releases based on this signal
name: Deploy
on:
pull_request:
branches:
- main
# The only commits that will contain changes to the masterlist will be releases
paths:
- 'MASTERLIST.md'
workflow_dispatch:
inputs:
# For this workflow, BUILD_ALL will cause all adapters to have their image built and deployed
build-all:
description: whether to run steps for all adapters, regardless of whether they were changed in this event
required: false
default: 'false'
concurrency:
group: deploy-and-release
cancel-in-progress: false
jobs:
calculate-changes:
name: Compute changed adapters
runs-on: [ubuntu-latest]
outputs:
adapter-list: ${{ steps.changed-adapters.outputs.CHANGED_ADAPTERS }}
tmp-branch: ${{ steps.push-branch.outputs.TMP_BRANCH }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 3
- name: Build list of changed packages and changed adapters
id: changed-adapters
env:
UPSTREAM_BRANCH: ${{ github.event.pull_request.base.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git fetch --no-tags --depth=3 origin ${{ github.event.pull_request.base.sha }}
./.github/scripts/changed-adapters.sh
deploy:
name: Trigger infra deployment
permissions:
id-token: write
contents: read
runs-on: ubuntu-latest
needs:
- calculate-changes
if: needs.calculate-changes.outputs.adapter-list != '[]'
#environment: InfraK8s
env:
# ECR_URL: ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com
ECR_URL: 1234.dkr.ecr.us-west-2.amazonaws.com
CHANGED_ADAPTERS: ${{ needs.calculate-changes.outputs.adapter-list }}
steps:
- name: Setup GitHub Token
if: false
id: setup-github-token
uses: smartcontractkit/.github/actions/setup-github-token@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # setup-github-token@0.1.2
with:
aws-role-arn: ${{ secrets.AWS_ROLE_ARN_FOR_INFRA_K8s_PAT }}
aws-lambda-url: ${{ secrets.GATI_LAMBDA_DATA_FEEDS_URL }}
aws-region: ${{ secrets.AWS_REGION }}
aws-role-duration-seconds: '1800' # this is optional and defaults to 900
- name: Determine branch name suffix
id: suffix
run: |
echo "github.event.pull_request.head.ref = ${{ github.event.pull_request.head.ref }}"
if [[ "${{ github.event.pull_request.head.ref }}" = "changeset-release/main" ]]; then
echo "SUFFIX=" >> $GITHUB_OUTPUT
else
echo "SUFFIX=-pr${{ github.event.number }}" >> $GITHUB_OUTPUT
fi
- name: Trigger Image Dispatcher
run: >
echo gh workflow run
--repo smartcontractkit/infra-k8s
--ref main "Infra-k8s Image Dispatcher"
-F imageRepos="$(echo $CHANGED_ADAPTERS | jq -r "\"$ECR_URL/adapters/\" + (.adapter | .[].shortName) + \"-adapter\"" | tr '\n' ' ')"
-F gitRepo="${{ github.event.repository.name }}${{ steps.suffix.outputs.SUFFIX }}"