Skip to content

Commit b39bd6a

Browse files
authored
Revert "OPDATA-3845: Trigger 'deploy' workflow from release PR (#4143)" (#4155)
This reverts commit 606df49.
1 parent 606df49 commit b39bd6a

File tree

3 files changed

+58
-84
lines changed

3 files changed

+58
-84
lines changed

.github/scripts/changed-adapters.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
#!/bin/bash -e
22

33
# If BUILD_ALL is true, then we want to generate lists with all packages regardless of changes
4-
# If ADAPTER_NAMES is set, then we want to generate lists with only those adapters. ADAPTER_NAMES should be a comma-separated list of short names (e.g. "coinpaprika,coingecko")
54
if [[ $BUILD_ALL = true ]]; then
65
PACKAGE_LIST=$(yarn workspaces list -R --json)
7-
elif [[ -n "$ADAPTER_NAMES" ]]; then
8-
PACKAGE_LIST=$(yarn workspaces list -R --json | jq --arg list "$ADAPTER_NAMES" '($list | split(",")) as $shortNames | select(.name as $name | $shortNames | any($name == "@chainlink/" + . + "-adapter"))')
96
else
107
PACKAGE_LIST=$(yarn workspaces list -R --json --since=$UPSTREAM_BRANCH)
118
fi

.github/workflows/deploy-from-pr.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44
name: Deploy
55

66
on:
7+
push:
8+
branches:
9+
- main
10+
# The only commits that will contain changes to the masterlist will be releases
11+
paths-ignore:
12+
- 'MASTERLIST.md'
13+
- 'package.json'
14+
- '.changeset/**'
15+
- 'packages/**/CHANGELOG.md'
16+
- 'packages/**/README.md'
17+
- 'packages/**/package.json'
718
workflow_dispatch:
819
inputs:
9-
adapters:
10-
description: Names of adapters to deploy
11-
required: true
12-
infra-k8s-branch-suffix:
13-
description: Suffix to append to infra-k8s branch name. Must be non-empty if not triggered by the full release PR.
20+
# For this workflow, BUILD_ALL will cause all adapters to have their image built and deployed
21+
build-all:
22+
description: whether to run steps for all adapters, regardless of whether they were changed in this event
1423
required: false
15-
default: ''
24+
default: 'false'
1625

1726
concurrency:
1827
group: deploy-and-release
@@ -24,16 +33,42 @@ jobs:
2433
runs-on: [ubuntu-latest]
2534
outputs:
2635
adapter-list: ${{ steps.changed-adapters.outputs.CHANGED_ADAPTERS }}
36+
tmp-branch: ${{ steps.push-branch.outputs.TMP_BRANCH }}
2737
steps:
2838
- uses: actions/checkout@v5
2939
with:
3040
fetch-depth: 2
41+
- name: Set up and install dependencies
42+
uses: ./.github/actions/setup
43+
with:
44+
skip-setup: true
3145
- name: Build list of changed packages and changed adapters
3246
id: changed-adapters
3347
env:
34-
ADAPTER_NAMES: ${{ github.event.inputs.adapters }}
48+
UPSTREAM_BRANCH: HEAD~1
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3550
run: |
51+
# The deployment will overwrite existing ones, so in order to calculate all adapters that have been changed,
52+
# we can mock running the changesets version command to have them present in the diff.
53+
# Additionally, running the changeset version will cause the images we publish here to have the proper increased version.
54+
yarn changeset version
55+
56+
# If there are changes, commit them and calculate the adapters.
57+
# If there are no changes, we don't need to deploy anything :)
58+
if [[ `git status --porcelain` ]]; then
59+
git commit -am "Mock changesets"
60+
fi
61+
3662
./.github/scripts/changed-adapters.sh
63+
# Since we want to publish with the versions updated, we need to store the changes we've made to a temporary branch
64+
- name: Publish branch
65+
id: push-branch
66+
if: steps.changed-adapters.outputs.CHANGED_ADAPTERS != '[]'
67+
run: |
68+
export TMP_BRANCH="tmp-deploy-$(git rev-parse HEAD)"
69+
git checkout -b tmp-deploy-$(git rev-parse HEAD)
70+
git push origin tmp-deploy-$(git rev-parse HEAD)
71+
echo "TMP_BRANCH=$TMP_BRANCH" >> $GITHUB_OUTPUT
3772
3873
create-ecr:
3974
name: Create ECR for ${{ matrix.adapter.shortName }}
@@ -112,7 +147,6 @@ jobs:
112147
env:
113148
ECR_URL: ${{ secrets.SDLC_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION_ECR_PRIVATE }}.amazonaws.com
114149
CHANGED_ADAPTERS: ${{ needs.calculate-changes.outputs.adapter-list }}
115-
BRANCH_SUFFIX: ${{ github.event.inputs.infra-k8s-branch-suffix }}
116150
steps:
117151
- name: Setup GitHub Token
118152
id: setup-github-token
@@ -124,12 +158,25 @@ jobs:
124158
aws-role-duration-seconds: '1800' # this is optional and defaults to 900
125159
- name: Trigger Image Dispatcher
126160
run: >
127-
# gitRepo does not need to be an actual repo name. It is only used
128-
# in the branch name, PR title, and PR description in infra-k8s.
129161
gh workflow run
130162
--repo smartcontractkit/infra-k8s
131163
--ref main "Infra-k8s Image Dispatcher"
132164
-F imageRepos="$(echo $CHANGED_ADAPTERS | jq -r "\"$ECR_URL/adapters/\" + (.adapter | .[].shortName) + \"-adapter\"" | tr '\n' ' ')"
133-
-F gitRepo="${{ github.event.repository.name }}$BRANCH_SUFFIX"
165+
-F gitRepo=${{ github.event.repository.name }}
134166
env:
135167
GITHUB_TOKEN: ${{ steps.setup-github-token.outputs.access-token }}
168+
169+
cleanup:
170+
name: Clean up ephemeral items
171+
runs-on: ubuntu-latest
172+
needs:
173+
- calculate-changes
174+
- deploy
175+
if: always() && needs.calculate-changes.outputs.adapter-list != '[]'
176+
steps:
177+
- uses: actions/checkout@v5
178+
with:
179+
ref: ${{ needs.calculate-changes.outputs.tmp-branch }}
180+
- name: Delete ephemeral branch
181+
run: |
182+
git push origin --delete ${{ needs.calculate-changes.outputs.tmp-branch }}

0 commit comments

Comments
 (0)