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

Update build image workflow #32

Merged
merged 2 commits into from
Oct 21, 2024
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
69 changes: 55 additions & 14 deletions .github/workflows/build-and-push.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push image to to JFROG Public
name: Push image to JFROG Public

on:
push:
Expand All @@ -13,17 +13,58 @@ permissions:
contents: read

jobs:
build:
name: Build and Push Docker Images
strategy:
matrix:
include:
- directory: operator
repository: elasti-operator
- directory: resolver
repository: elasti-resolver
uses: truefoundry/workflows/.github/workflows/build-elasti.yml@main
get_changed_files:
name: Get the changed files
runs-on: ubuntu-latest
outputs:
operator_changed: ${{ steps.check_operator_files.outputs.operator_changed }}
resolver_changed: ${{ steps.check_resolver_files.outputs.resolver_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get the changed files
id: get_changed_files
run: |
files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | tr '\n' ' ')
echo "files=$files" >> $GITHUB_OUTPUT

- name: Check if operator files changed
id: check_operator_files
run: echo "operator_changed=${{ contains(steps.get_changed_files.outputs.files, 'operator/') }}" >> $GITHUB_OUTPUT

- name: Check if resolver files changed
id: check_resolver_files
run: echo "resolver_changed=${{ contains(steps.get_changed_files.outputs.files, 'resolver/') }}" >> $GITHUB_OUTPUT

build-operator:
name: Build and Push Operator Docker Images
if: needs.get_changed_files.outputs.operator_changed == 'true'
needs: get_changed_files
uses: truefoundry/workflows/.github/workflows/build.yml@main
with:
image_tag: ${{ github.sha }}
image_artifact_name: 'elasti-operator'
dockerfile_path: 'operator/Dockerfile'
artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }}
artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }}
secrets:
artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }}
artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }}

build-resolver:
name: Build and Push Resolver Docker Images
if: needs.get_changed_files.outputs.resolver_changed == 'true'
needs: get_changed_files
uses: truefoundry/workflows/.github/workflows/build.yml@main
with:
directory: ${{ matrix.directory}}
repository: ${{ matrix.repository}}
secrets: inherit
image_tag: ${{ github.sha }}
image_artifact_name: 'elasti-resolver'
dockerfile_path: 'resolver/Dockerfile'
artifactory_registry_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_REGISTRY_URL }}
artifactory_repository_url: ${{ vars.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_REPOSITORY }}
secrets:
artifactory_username: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_USERNAME }}
artifactory_password: ${{ secrets.TRUEFOUNDRY_ARTIFACTORY_PUBLIC_PASSWORD }}
Loading