44name : Deploy
55
66on :
7- push :
7+ pull_request :
88 branches :
99 - main
1010 # The only commits that will contain changes to the masterlist will be releases
11- paths-ignore :
11+ paths :
1212 - ' MASTERLIST.md'
13- - ' package.json'
14- - ' .changeset/**'
15- - ' packages/**/CHANGELOG.md'
16- - ' packages/**/README.md'
17- - ' packages/**/package.json'
1813 workflow_dispatch :
1914 inputs :
2015 # For this workflow, BUILD_ALL will cause all adapters to have their image built and deployed
@@ -39,82 +34,13 @@ jobs:
3934 uses : actions/checkout@v4
4035 with :
4136 fetch-depth : 2
42- - name : Set up and install dependencies
43- uses : ./.github/actions/setup
44- with :
45- skip-setup : true
4637 - name : Build list of changed packages and changed adapters
4738 id : changed-adapters
4839 env :
49- UPSTREAM_BRANCH : HEAD~1
40+ UPSTREAM_BRANCH : main
5041 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5142 run : |
52- # The deployment will overwrite existing ones, so in order to calculate all adapters that have been changed,
53- # we can mock running the changesets version command to have them present in the diff.
54- # Additionally, running the changeset version will cause the images we publish here to have the proper increased version.
55- yarn changeset version
56-
57- # If there are changes, commit them and calculate the adapters.
58- # If there are no changes, we don't need to deploy anything :)
59- if [[ `git status --porcelain` ]]; then
60- git commit -am "Mock changesets"
61- fi
62-
6343 ./.github/scripts/changed-adapters.sh
64- # Since we want to publish with the versions updated, we need to store the changes we've made to a temporary branch
65- - name : Publish branch
66- id : push-branch
67- if : steps.changed-adapters.outputs.CHANGED_ADAPTERS != '[]'
68- run : |
69- export TMP_BRANCH="tmp-deploy-$(git rev-parse HEAD)"
70- git checkout -b tmp-deploy-$(git rev-parse HEAD)
71- git push origin tmp-deploy-$(git rev-parse HEAD)
72- echo "TMP_BRANCH=$TMP_BRANCH" >> $GITHUB_OUTPUT
73-
74- publish-adapter-images :
75- name : Build and publish ${{ matrix.adapter.shortName }}
76- runs-on : ubuntu-latest
77- needs :
78- - calculate-changes
79- if : needs.calculate-changes.outputs.adapter-list != '[]'
80- environment : release
81- permissions : # These are needed for the configure-aws-credentials action
82- id-token : write
83- contents : read
84- strategy :
85- max-parallel : 20
86- matrix : ${{fromJson(needs.calculate-changes.outputs.adapter-list)}}
87- env :
88- ECR_URL : ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com
89- ECR_REPO : adapters/${{ matrix.adapter.shortName }}-adapter
90- IMAGE_VERSION : ${{ matrix.adapter.version }}
91- steps :
92- - name : Check out code
93- uses : actions/checkout@v4
94- with :
95- ref : ${{ needs.calculate-changes.outputs.tmp-branch }}
96- - name : Build the adapter image
97- uses : docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
98- with :
99- context : .
100- push : false
101- tags : ${{ env.ECR_URL }}/${{ env.ECR_REPO }}:${{ matrix.adapter.version }}
102- build-args : |
103- package=${{ matrix.adapter.name }}
104- location=${{ matrix.adapter.location }}
105- - name : Debug
106- run : docker image ls
107- - name : Publish adapter image
108- uses : ./.github/actions/publish-image
109- with :
110- image-version : ${{ matrix.adapter.version }}
111- aws-ecr-url : ${{ env.ECR_URL }}
112- aws-ecr-repo : ${{ env.ECR_REPO }}
113- aws-region : ${{ secrets.AWS_REGION_ECR_PRIVATE }}
114- aws-role : ${{ secrets.AWS_OIDC_IAM_ROLE_ARN }}
115- aws-ecr-account-ids : ${{ secrets.AWS_PRIVATE_ECR_SECONDARY_ACCOUNT_ACCESS_IDS }}
116- aws-ecr-private : true
117- latest : true
11844
11945 deploy :
12046 name : Trigger infra deployment
12450 runs-on : ubuntu-latest
12551 needs :
12652 - calculate-changes
127- - publish-adapter-images
12853 if : needs.calculate-changes.outputs.adapter-list != '[]'
12954 environment : InfraK8s
13055 env :
@@ -145,22 +70,6 @@ jobs:
14570 --repo smartcontractkit/infra-k8s
14671 --ref main "Infra-k8s Image Dispatcher"
14772 -F imageRepos="$(echo $CHANGED_ADAPTERS | jq -r "\"$ECR_URL/adapters/\" + (.adapter | .[].shortName) + \"-adapter\"" | tr '\n' ' ')"
148- -F gitRepo=${{ github.event.repository.name }}
73+ -F gitRepo=" ${{ github.event.repository.name }}-test"
14974 env :
15075 GITHUB_TOKEN : ${{ steps.setup-github-token.outputs.access-token }}
151-
152- cleanup :
153- name : Clean up ephemeral items
154- runs-on : ubuntu-latest
155- needs :
156- - calculate-changes
157- - deploy
158- if : always() && needs.calculate-changes.outputs.adapter-list != '[]'
159- steps :
160- - name : Check out code
161- uses : actions/checkout@v4
162- with :
163- ref : ${{ needs.calculate-changes.outputs.tmp-branch }}
164- - name : Delete ephemeral branch
165- run : |
166- git push origin --delete ${{ needs.calculate-changes.outputs.tmp-branch }}
0 commit comments