Skip to content

Commit

Permalink
variable creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sarathchandra24 committed Mar 3, 2024
1 parent b63d55e commit 58fd9da
Showing 1 changed file with 48 additions and 24 deletions.
72 changes: 48 additions & 24 deletions .github/workflows/build-op-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,55 @@ on:
- 'master'

env:
REGISTRY_REPO: 'sarathchandra24'
DOCKER_REPO: 'sarathchandra24'
DOCKER_IMAGE: 'fluent-operator'
GITHUB_IMAGE: "${{ github.repository }}/fluent-operator"

jobs:
build-image-metadata:
runs-on: ubuntu-latest
name: Build Image Metadata
outputs:
FULL_IMG_NAME: ${{ steps.set-outputs.outputs.FULL_IMAGE_NAME }}
IMG_NAME: ${{ steps.set-outputs.outputs.IMAGE_NAME }}
DOCKER_IMG_NAME: ${{ steps.set-outputs.outputs.DOCKER_IMG_NAME }}
version: ${{ steps.image-metadata.outputs.version }}
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install jq
uses: dcarbone/[email protected]

- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Set outputs
id: set-outputs
run: |
echo "FULL_IMAGE_NAME=$(${{ steps.image-metadata.outputs.json }} | jq '.tags[0]')" >> $GITHUB_OUTPUT
echo "IMAGE_NAME=${{ env.GITHUB_IMAGE }}" >> $GITHUB_OUTPUT
echo "DOCKER_IMG_NAME=${{env.DOCKER_REPO}}/${{ env.DOCKER_IMAGE }}" >> $GITHUB_OUTPUT
operator-build:
runs-on: ubuntu-latest
timeout-minutes: 30
name: Build Image for Fluent Operator
outputs:
IMG_VERSION: ${{ steps.image-metadata.outputs.version }}
IMG_NAME: ${{ steps.image-metadata.outputs.tags }}
OPERATOR_DOCKER_IMG: "${{ env.REGISTRY_REPO }}/${{ env.DOCKER_IMAGE }}"

needs:
- build-image-metadata
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -56,19 +91,6 @@ jobs:
registry: ghcr.io
username: ${{ github.actor_id }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker metadata
id: image-metadata
uses: docker/metadata-action@v5
with:
images: "ghcr.io/${{ env.GITHUB_IMAGE }}"
tags: |
raw,latest
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}

- name: Build and push
uses: docker/build-push-action@v2
Expand All @@ -77,16 +99,17 @@ jobs:
file: ./cmd/fluent-manager/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.image-metadata.outputs.tags }}
labels: ${{ steps.image-metadata.outputs.labels }}
tags: ${{ needs.build-image-metadata.outputs.tags }}
labels: ${{ needs.build-image-metadata.outputs.labels }}

scan-operator-image:
name: Scan Docker Image
needs:
- operator-build
- build-image-metadata
uses: ./.github/workflows/call-scan-images.yaml
with:
source_image: "${{ needs.operator-build.outputs.IMG_NAME }}"
source_image: "${{ needs.build-image-metadata.outputs.FULL_IMG_NAME }}"
source_registry: ghcr.io
platforms: '["linux/arm64", "linux/amd64"]'
secrets:
Expand All @@ -100,10 +123,11 @@ jobs:
needs:
- operator-build
- scan-operator-image
- build-image-metadata
with:
source_image: "${{ needs.operator-build.outputs.IMG_NAME }}"
source_image: "${{ needs.build-image-metadata.outputs.FULL_IMG_NAME }}"
source_registry: ghcr.io
target_image: ${{ needs.operator-build.outputs.OPERATOR_DOCKER_IMG }}
target_image: ${{ needs.build-image-metadata.outputs.DOCKER_IMG_NAME }}
target_registry: docker.io
platforms: "['linux/arm64', 'linux/amd64']"
secrets:
Expand Down

0 comments on commit 58fd9da

Please sign in to comment.