Skip to content

Commit

Permalink
ci: fixing docker auth for pushing images on release
Browse files Browse the repository at this point in the history
  • Loading branch information
ziegfried committed Mar 7, 2020
1 parent 9cf26dd commit f8e3f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ jobs:
run: |
yarn install --frozen-lockfile
yarn semantic-release
docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
yarn ts-node scripts/postrelease.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 7 additions & 3 deletions scripts/postrelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ export async function main(args: string[]) {
if (process.env.DOCKER_HUB_TOKEN) {
console.log('Logging in to docker hub');
await execa('docker', ['login', '-u', 'dltbuilder', '-p', process.env.DOCKER_HUB_TOKEN]);
}
let publishedToDockerhub = false;
try {
await publishImageVersions(DOCKER_HUB_IMAGE);
} else {
console.log('No docker hub token set. Skipping publish to docker hub.');
publishedToDockerhub = true;
} catch (e) {
console.log('Failed to push image to docker hub:', e.message);
}

const bullet = (prefix: string, title: string, href: string) => `- ${prefix}: [${title}](${href})`;
Expand All @@ -112,7 +116,7 @@ export async function main(args: string[]) {
semver.version
)}`
),
process.env.DOCKER_HUB_TOKEN != null
publishedToDockerhub
? bullet(
'Docker image on docker hub',
`${DOCKER_HUB_IMAGE}:${semver.version}`,
Expand Down

0 comments on commit f8e3f3d

Please sign in to comment.