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

feat: support build_args in argus docker builder workflow #276

Merged
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
30 changes: 17 additions & 13 deletions .github/workflows/argus-docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get build tag
id: build-tags
run: |
echo "IMAGE_TAG=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Validate build tag
id: validate_image_tag
uses: actions/github-script@v7
with:
script: |
const imageTag = `${{ steps.build-tags.outputs.IMAGE_TAG }}`;
core.setOutput('image_tag_valid', imageTag !== '' && imageTag !== 'sha-');
- name: Parse inputs
id: parse_inputs
uses: actions/github-script@v7
Expand All @@ -92,6 +103,11 @@ jobs:
core.setOutput('filters', filtersStr);

const images = JSON.parse(`${{ inputs.images }}`);
images.forEach(image => {
const buildArgs = image.build_args || [];
image.build_args = ["IMAGE_TAG=${{ steps.build-tags.outputs.IMAGE_TAG }}", ...buildArgs].join("\n");
});
core.info(`Images to build: ${JSON.stringify(images, null, 2)}`);
core.setOutput('images', images);

const envs = `${{ inputs.envs }}`.split(',').map(env => env.trim()).filter(b => b.length > 0);
Expand All @@ -105,17 +121,6 @@ jobs:
${{ steps.parse_inputs.outputs.filters }}
base: ${{ inputs.path_filters_base }}
list-files: json
- name: Get build tag
id: build-tags
run: |
echo "IMAGE_TAG=sha-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Validate build tag
id: validate_image_tag
uses: actions/github-script@v7
with:
script: |
const imageTag = `${{ steps.build-tags.outputs.IMAGE_TAG }}`;
core.setOutput('image_tag_valid', imageTag !== '' && imageTag !== 'sha-');

build-docker:
name: Build Docker Image
Expand Down Expand Up @@ -172,8 +177,7 @@ jobs:
registry: 533267185808.dkr.ecr.us-west-2.amazonaws.com
custom_tag: ${{ env.IMAGE_TAG }}
platforms: ${{ matrix.image.platform == 'linux/amd64' && 'linux/amd64' || 'linux/arm64' }}
build_args: IMAGE_TAG=${{ env.IMAGE_TAG }}

build_args: ${{ matrix.image.build_args }}
update-manifests:
name: Update ArgoCD manifests
needs: [prep, build-docker]
Expand Down
Loading