Skip to content

Commit

Permalink
Extract updater/proxy tags from Dockerfile
Browse files Browse the repository at this point in the history
This could allow Dependabot to keep the `Dockerfile` up-to-date, and we
wouldn't need another build step to use them.

When running `ncc build` the referenced `Dockerfile` gets copied into
`dist/main` so it's available to the code running in actions.

Following on from: https://github.com/dependabot/updater-action/pull/72
Working towards: github/dependabot-updates#2102
  • Loading branch information
Philip Harrison authored and Barry Gordon committed Feb 23, 2022
1 parent 360cc5e commit c44504b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NOTE: This Dockerfile is unused, it's only here so Dependabot can update the sha's

# TODO: Pin to sha256
FROM docker.pkg.github.com/dependabot/dependabot-updater:v1
FROM docker.pkg.github.com/github/dependabot-update-job-proxy:v1
30 changes: 26 additions & 4 deletions src/docker-tags.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
export const UPDATER_IMAGE_NAME =
'docker.pkg.github.com/dependabot/dependabot-updater:v1'
export const PROXY_IMAGE_NAME =
'docker.pkg.github.com/github/dependabot-update-job-proxy:v1'
import fs from 'fs'

const dockerfile = fs.readFileSync(require.resolve('../Dockerfile'), 'utf8')

const imageNames = dockerfile
.split(/\n/)
.filter(a => a.startsWith('FROM'))
.map(a => a.replace('FROM', '').trim())

const updaterImageName = imageNames.find(a =>
a.includes('dependabot/dependabot-updater')
)
const proxyImageName = imageNames.find(a =>
a.includes('github/dependabot-update-job-proxy')
)

if (!updaterImageName) {
throw new Error('Could not find dependabot-updater image name')
}

if (!proxyImageName) {
throw new Error('Could not find dependabot-update-job-proxy image name')
}

export const UPDATER_IMAGE_NAME = updaterImageName
export const PROXY_IMAGE_NAME = proxyImageName

0 comments on commit c44504b

Please sign in to comment.