Skip to content

Commit

Permalink
build: tag docker with develop merge (#768)
Browse files Browse the repository at this point in the history
* build: tag docker with develop merge
  • Loading branch information
tea-artist authored Jul 26, 2024
1 parent 2103750 commit 411acc1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:
- 'apps/nextjs-app/**'
- 'packages/core/**'
- 'packages/sdk/**'
- '.github/**'
- 'scripts/**'

jobs:
build-push:
Expand Down Expand Up @@ -66,10 +68,8 @@ jobs:
ghcr.io/teableio/${{ matrix.image }}
docker.io/teableio/${{ matrix.image }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=latest
- name: ⚙️ Set up QEMU
uses: docker/setup-qemu-action@v3
- name: ⚙️ Set up Docker Buildx
Expand Down
15 changes: 11 additions & 4 deletions scripts/build-image.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const getSemver = async () => {
const runNumber = env.GITHUB_RUN_NUMBER;
const sha = env.GITHUB_SHA.substring(0, 7);

console.log('refType: ', refType);
console.log('runNumber: ', runNumber);
console.log('sha: ', sha);

switch (refType) {
case 'branch':
semver = `${version}-alpha+build.${runNumber}.sha-${sha}`;
Expand All @@ -44,7 +48,7 @@ const getSemver = async () => {
break;
}
}

console.log('semver: ', semver);
return semver;
};

Expand Down Expand Up @@ -92,7 +96,8 @@ const push = toBoolean(pushArg);
const command = ['docker', 'buildx', 'build'];

// BUILD_VERSION - this is a default behavior
command.push('--build-arg', `BUILD_VERSION=${await getSemver()}`);
const semver = await getSemver();
command.push('--build-arg', `BUILD_VERSION=${semver}`);

await asyncForEach(buildArgs, async (buildArg) => {
command.push('--build-arg', buildArg);
Expand All @@ -109,8 +114,10 @@ if (file) {
if (platforms.length > 0) {
command.push('--platform', platforms.join(','));
}
await asyncForEach(tags, async (tag) => {
command.push('--tag', `${tag}${tagSuffix ?? ''}`);
await asyncForEach(tags, async (fullName) => {
const [image, tag] = fullName.split(':');
command.push('--tag', `${image}:${tag}${tagSuffix ?? ''}`);
command.push('--tag', `${image}:${semver}`);
});

if (push) {
Expand Down

0 comments on commit 411acc1

Please sign in to comment.