Skip to content

Commit

Permalink
Silently continue when the certificate variable is not set.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jan 12, 2020
1 parent d17a7e6 commit 5f4d803
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
cd files
mkdir subdirectory
copy C:\Windows\System32\wmi.dll subdirectory
- name: Run the action with missing certificate
uses: ./
with:
certificate: '${{ secrets.MISSING_CERTIFICATE }}'
folder: 'files'
- name: Run the action
uses: ./
with:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ function sleep(seconds: number) {
}

async function createCertificatePfx() {
const base64Certificate = core.getInput('certificate', { required: true });
const base64Certificate = core.getInput('certificate');
const certificate = Buffer.from(base64Certificate, 'base64');
if (certificate.length == 0)
throw 'certificate value is not set.';
if (certificate.length == 0) {
console.log('certificate value is not set.');
return false;
}
console.log(`Writing ${certificate.length} bytes to ${certificateFileName}.`);
await fs.writeFile(certificateFileName, certificate);
return true;
}

async function downloadNuGet() {
Expand Down Expand Up @@ -114,8 +117,8 @@ async function signFiles() {

async function run() {
try {
await createCertificatePfx();
await signFiles();
if (await createCertificatePfx())
await signFiles();
}
catch (err) {
core.setFailed(`Action failed with error: ${err}`);
Expand Down

0 comments on commit 5f4d803

Please sign in to comment.