Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate datestamps during docker bake and not on merge #1132

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/blueprints/workflows/os-arch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ output:
registry: docker.io
username: ${{ secrets.BALENAIMAGES_USER }}
password: ${{ secrets.BALENAIMAGES_TOKEN }}
- name: Set the DATESTAMP variable
run: echo "DATESTAMP=$(date +%Y%m%d)" >> "${GITHUB_ENV}"
# https://github.com/docker/bake-action
- name: Docker bake
continue-on-error: false
Expand Down
2 changes: 2 additions & 0 deletions scripts/blueprints/workflows/os-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ output:
registry: docker.io
username: ${{ secrets.BALENAIMAGES_USER }}
password: ${{ secrets.BALENAIMAGES_TOKEN }}
- name: Set the DATESTAMP variable
run: echo "DATESTAMP=$(date +%Y%m%d)" >> "${GITHUB_ENV}"
# https://github.com/docker/bake-action
- name: Docker bake
continue-on-error: false
Expand Down
2 changes: 2 additions & 0 deletions scripts/blueprints/workflows/stack-arch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ output:
registry: docker.io
username: ${{ secrets.BALENAIMAGES_USER }}
password: ${{ secrets.BALENAIMAGES_TOKEN }}
- name: Set the DATESTAMP variable
run: echo "DATESTAMP=$(date +%Y%m%d)" >> "${GITHUB_ENV}"
# https://github.com/docker/bake-action
- name: Docker bake
continue-on-error: false
Expand Down
2 changes: 2 additions & 0 deletions scripts/blueprints/workflows/stack-device.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ output:
registry: docker.io
username: ${{ secrets.BALENAIMAGES_USER }}
password: ${{ secrets.BALENAIMAGES_TOKEN }}
- name: Set the DATESTAMP variable
run: echo "DATESTAMP=$(date +%Y%m%d)" >> "${GITHUB_ENV}"
# https://github.com/docker/bake-action
- name: Docker bake
continue-on-error: false
Expand Down
21 changes: 11 additions & 10 deletions scripts/generate-bakefiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@ const balena = getSdk({
dataDirectory: false,
});

function yyyymmdd() {
const now = new Date();
const y = now.getFullYear();
const m = now.getMonth() + 1;
const d = now.getDate();
return '' + y + (m < 10 ? '0' : '') + m + (d < 10 ? '0' : '') + d;
}

function getVersionAliases(version, latestVersion, generateAllAliases = true) {
// version can be a full version x.y.z or x.y or just x (only for latest version if generateAllAliases is false).
const result = [version];
Expand Down Expand Up @@ -150,6 +142,11 @@ function generateBakeFile(context, tags) {
cache_from: tags,
},
},
variable: {
DATESTAMP: {
default: '$DATESTAMP',
},
},
};

const destination = path.join(DEST_DIR, context.imageName + '.json');
Expand Down Expand Up @@ -196,7 +193,11 @@ async function generateOsArchLibrary(context) {
}

let repo = [NAMESPACE, context.imageName].join('/');
const tags = generateCombinations([osVersions, variants, [yyyymmdd(), null]]);
const tags = generateCombinations([
osVersions,
variants,
['${DATESTAMP}', null],
]);

// loop over all tags and append the repo as a prefix
let repoTags = tags.map((tag) => {
Expand Down Expand Up @@ -257,7 +258,7 @@ async function generateStackLibrary(context) {
stackVersions,
osVersions,
variants,
[yyyymmdd(), null],
['${DATESTAMP}', null],
]);

// loop over all tags and append the repo as a prefix
Expand Down