File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,6 +105,44 @@ jobs:
105105 pull-requests : read
106106 packages : write
107107 steps :
108+ - name : Wait for package visibility
109+ uses : actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
110+ env :
111+ IMAGE : ${{ matrix.image }}
112+ with :
113+ script : |
114+ const sleep = (delayMs) =>
115+ new Promise((resolve) => setTimeout(resolve, delayMs));
116+
117+ const owner = context.repo.owner;
118+ const packageName = `${context.repo.repo.toLowerCase()}/${process.env.IMAGE}`;
119+ const packagePayload = {
120+ package_type: 'container',
121+ package_name: packageName,
122+ org: owner,
123+ };
124+
125+ for (let attempt = 1; attempt <= 6; attempt++) {
126+ try {
127+ await github.rest.packages.getPackageForOrganization(packagePayload);
128+ core.info(`Package "${packageName}" is visible.`);
129+ return;
130+ } catch (error) {
131+ if (error.status !== 404 || attempt === 6) {
132+ throw error;
133+ }
134+
135+ core.info(
136+ [
137+ `Package "${packageName}" is not visible yet`,
138+ `(attempt ${attempt}/6).`,
139+ 'Retrying in 5000 ms.',
140+ ].join(' '),
141+ );
142+ await sleep(5000);
143+ }
144+ }
145+
108146 - id : local-workflow-actions
109147 uses : hoverkraft-tech/ci-github-common/actions/local-workflow-actions@2334d395217f9811699dbd4ace9d8559e4d99e0d # 0.37.3
110148 with :
You can’t perform that action at this time.
0 commit comments