@@ -38,12 +38,21 @@ jobs:
3838 return [context.ref.replace('refs/tags/', '')];
3939 }
4040
41- const directory = await github.rest.repos.getContent({
42- owner: context.repo.owner,
43- repo: context.repo.repo,
44- path: 'docs/release-notes',
45- ref: defaultBranch,
46- });
41+ let directory;
42+ try {
43+ directory = await github.rest.repos.getContent({
44+ owner: context.repo.owner,
45+ repo: context.repo.repo,
46+ path: 'docs/release-notes',
47+ ref: defaultBranch,
48+ });
49+ } catch (error) {
50+ if (error.status === 404) {
51+ core.info('docs/release-notes does not exist on the default branch; nothing to release.');
52+ return [];
53+ }
54+ throw error;
55+ }
4756
4857 if (!Array.isArray(directory.data)) {
4958 throw new Error('docs/release-notes must be a directory.');
@@ -86,12 +95,21 @@ jobs:
8695 const notesPath = `docs/release-notes/${tag}.md`;
8796 const ref = context.ref.startsWith('refs/tags/') ? tag : defaultBranch;
8897
89- const file = await github.rest.repos.getContent({
90- owner: context.repo.owner,
91- repo: context.repo.repo,
92- path: notesPath,
93- ref,
94- });
98+ let file;
99+ try {
100+ file = await github.rest.repos.getContent({
101+ owner: context.repo.owner,
102+ repo: context.repo.repo,
103+ path: notesPath,
104+ ref,
105+ });
106+ } catch (error) {
107+ if (error.status === 404) {
108+ core.info(`Skipping ${tag}; ${notesPath} was not found at ref ${ref}.`);
109+ return { tag, status: 'missing-notes' };
110+ }
111+ throw error;
112+ }
95113
96114 if (!file.data || !file.data.content) {
97115 throw new Error(`Unable to read ${notesPath} at ref ${ref}`);
0 commit comments