Skip to content

Commit fd571a7

Browse files
committed
Split publish and deploy workflows
1 parent 95a3664 commit fd571a7

File tree

2 files changed

+7
-133
lines changed

2 files changed

+7
-133
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
name: Deploy
55

66
on:
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
@@ -124,7 +50,6 @@ jobs:
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 }}

.github/workflows/publish.yml

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# This action acts as a signal dispatcher that fires whenever the release process has
2-
# successfully completed. The listening workflow within the infra-k8s repository has
3-
# a corresponding event handler to generate releases based on this signal
4-
name: Deploy
1+
# This workflow publishes docker images to ECR.
2+
name: Publish
53

64
on:
75
push:
@@ -116,45 +114,12 @@ jobs:
116114
aws-ecr-private: true
117115
latest: true
118116

119-
deploy:
120-
name: Trigger infra deployment
121-
permissions:
122-
id-token: write
123-
contents: read
124-
runs-on: ubuntu-latest
125-
needs:
126-
- calculate-changes
127-
- publish-adapter-images
128-
if: needs.calculate-changes.outputs.adapter-list != '[]'
129-
environment: InfraK8s
130-
env:
131-
ECR_URL: ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com
132-
CHANGED_ADAPTERS: ${{ needs.calculate-changes.outputs.adapter-list }}
133-
steps:
134-
- name: Setup GitHub Token
135-
id: setup-github-token
136-
uses: smartcontractkit/.github/actions/setup-github-token@9e7cc0779934cae4a9028b8588c9adb64d8ce68c # [email protected]
137-
with:
138-
aws-role-arn: ${{ secrets.AWS_ROLE_ARN_FOR_INFRA_K8s_PAT }}
139-
aws-lambda-url: ${{ secrets.GATI_LAMBDA_DATA_FEEDS_URL }}
140-
aws-region: ${{ secrets.AWS_REGION }}
141-
aws-role-duration-seconds: '1800' # this is optional and defaults to 900
142-
- name: Trigger Image Dispatcher
143-
run: >
144-
gh workflow run
145-
--repo smartcontractkit/infra-k8s
146-
--ref main "Infra-k8s Image Dispatcher"
147-
-F imageRepos="$(echo $CHANGED_ADAPTERS | jq -r "\"$ECR_URL/adapters/\" + (.adapter | .[].shortName) + \"-adapter\"" | tr '\n' ' ')"
148-
-F gitRepo=${{ github.event.repository.name }}
149-
env:
150-
GITHUB_TOKEN: ${{ steps.setup-github-token.outputs.access-token }}
151-
152117
cleanup:
153118
name: Clean up ephemeral items
154119
runs-on: ubuntu-latest
155120
needs:
156121
- calculate-changes
157-
- deploy
122+
- publish-adapter-images
158123
if: always() && needs.calculate-changes.outputs.adapter-list != '[]'
159124
steps:
160125
- name: Check out code

0 commit comments

Comments
 (0)