Merge pull request #130 from utahudot/EventLogUtility-Aggregation #33
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Containers | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
changes: | |
name: Find Containers to build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Check which Containers have changed files | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: .github/filters.json | |
outputs: | |
changes: ${{steps.changes.outputs.changes}} | |
build: | |
name: Build Job | |
needs: changes | |
if: ${{ needs.changes.outputs.changes != '[]'}} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
name: ${{fromJson(needs.changes.outputs.changes)}} | |
steps: | |
- name: ⬇️ Set up code | |
uses: actions/checkout@v4 | |
- name: 📁 Get Working Dir | |
run: | | |
docker_dir="$(cat .github/filters.json | jq '."${{matrix.name}}"' | tr -d '**\n"')" | |
echo DOCKERFILE_DIR=${docker_dir} >> $GITHUB_ENV | |
- name: 🗝️ Authenticate to Google Cloud | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
create_credentials_file: true | |
token_format: access_token | |
workload_identity_provider: ${{ secrets.IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} | |
- name: 🐳 Set up Docker Buildx | |
id: builder | |
uses: docker/setup-buildx-action@v3 | |
- name: 🗝️ Authenticate Docker to Google Cloud | |
uses: docker/login-action@v3 | |
with: | |
registry: us-west3-docker.pkg.dev | |
username: oauth2accesstoken | |
password: ${{ steps.auth.outputs.access_token }} | |
- name: 🏷️ Extract tags from GitHub | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ vars.GCP_ARTIFACT_REPO }}/${{ matrix.name }} | |
tags: | | |
type=ref,suffix=-{{sha}},event=branch | |
type=ref,prefix=pr-,suffix=-{{sha}},event=pr | |
type=semver,pattern={{version}} | |
type=sha | |
latest | |
- name: 📦 Build and push image | |
uses: docker/build-push-action@v6 | |
if: ${{ matrix.name != 'atspm-webui'}} | |
with: | |
builder: ${{ steps.builder.outputs.name }} | |
tags: ${{ steps.meta.outputs.tags }} | |
context: Atspm/ | |
file: ${{ env.DOCKERFILE_DIR }}/Dockerfile | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: 📦 Build and push image WebUI | |
uses: docker/build-push-action@v6 | |
if: ${{ matrix.name == 'atspm-webui'}} | |
with: | |
builder: ${{ steps.builder.outputs.name }} | |
tags: ${{ steps.meta.outputs.tags }} | |
context: ${{ env.DOCKERFILE_DIR }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |