Skip to content

Commit

Permalink
Switched to recommended temp path
Browse files Browse the repository at this point in the history
  • Loading branch information
m-radmacher committed Oct 24, 2022
1 parent a928a9d commit 5e105f4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
10 changes: 7 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ function run() {
console.log('Fetching commits...');
const { commits, head, base } = yield fetchDataFromGitHub(token, owner, repo);
console.log('Creating PDF...');
core.debug('Temporary folder location: ' + process.env.RUNNER_TEMP);
createPDF(commits, owner, repo, language, base.name, head.name);
console.log('Wrote PDF file.');
if (uploadArtifact) {
console.log('Uploading artifact...');
yield artifact.create().uploadArtifact('changelog', ['D:/temp/changelog/output.pdf'], '.');
yield artifact
.create()
.uploadArtifact('changelog', [path_1.default.join(process.env.RUNNER_TEMP, 'output.pdf')], '.');
console.log('Uploaded artifact.');
}
if (sendEmail === true) {
Expand All @@ -157,7 +160,7 @@ function run() {
function createPDF(commits, owner, repo, language, baseTag, headTag) {
var _a, _b, _c;
const doc = new pdfkit_1.default();
doc.pipe(fs.createWriteStream('D:/temp/changelog/output.pdf'));
doc.pipe(fs.createWriteStream(path_1.default.join(process.env.RUNNER_TEMP, 'output.pdf')));
// list available fonts
if (fs.existsSync(path_1.default.join(__dirname, 'fonts'))) {
core.debug('Available fonts: ' + fs.readdirSync(path_1.default.join(__dirname, 'fonts')).join(', '));
Expand Down Expand Up @@ -291,6 +294,7 @@ const nodemailer = __importStar(__nccwpck_require__(4289));
const core = __importStar(__nccwpck_require__(2186));
const chalk_1 = __importDefault(__nccwpck_require__(8818));
const i18n_1 = __nccwpck_require__(2293);
const path_1 = __importDefault(__nccwpck_require__(1017));
function createMailTransport(host, port, secure, user, password) {
const transporter = nodemailer.createTransport({
host,
Expand Down Expand Up @@ -324,7 +328,7 @@ function sendChangelogMail(transporter, to, from, language, head, base) {
subject: language === 'de' ? (0, i18n_1.getGermanEmailSubject)(base, head) : (0, i18n_1.getEnglishEmailSubject)(base, head),
attachments: [
{
path: 'D:/temp/changelog/output.pdf',
path: path_1.default.join(process.env.RUNNER_TEMP, 'output.pdf'),
},
],
});
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ async function run() {
console.log('Fetching commits...');
const { commits, head, base } = await fetchDataFromGitHub(token, owner, repo);
console.log('Creating PDF...');
core.debug('Temporary folder location: ' + process.env.RUNNER_TEMP);
createPDF(commits, owner, repo, language, base.name, head.name);
console.log('Wrote PDF file.');
if (uploadArtifact) {
console.log('Uploading artifact...');
await artifact.create().uploadArtifact('changelog', ['D:/temp/changelog/output.pdf'], '.');
await artifact
.create()
.uploadArtifact('changelog', [path.join(process.env.RUNNER_TEMP as string, 'output.pdf')], '.');
console.log('Uploaded artifact.');
}
if (sendEmail === true) {
Expand All @@ -80,7 +83,7 @@ async function run() {

function createPDF(commits: Commit[], owner: string, repo: string, language: string, baseTag: string, headTag: string) {
const doc = new PDFDocument();
doc.pipe(fs.createWriteStream('D:/temp/changelog/output.pdf'));
doc.pipe(fs.createWriteStream(path.join(process.env.RUNNER_TEMP as string, 'output.pdf')));

// list available fonts
if (fs.existsSync(path.join(__dirname, 'fonts'))) {
Expand Down
3 changes: 2 additions & 1 deletion src/mailing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import SMTPTransport from 'nodemailer/lib/smtp-transport';
import * as core from '@actions/core';
import chalk from 'chalk';
import { getEnglishEmailSubject, getGermanEmailSubject } from './i18n';
import path from 'path';

export function createMailTransport(host: string, port: number, secure: boolean, user: string, password: string) {
const transporter = nodemailer.createTransport({
Expand Down Expand Up @@ -41,7 +42,7 @@ export async function sendChangelogMail(
subject: language === 'de' ? getGermanEmailSubject(base, head) : getEnglishEmailSubject(base, head),
attachments: [
{
path: 'D:/temp/changelog/output.pdf',
path: path.join(process.env.RUNNER_TEMP as string, 'output.pdf'),
},
],
});
Expand Down

0 comments on commit 5e105f4

Please sign in to comment.