Skip to content

Commit

Permalink
Move container build to gh runner
Browse files Browse the repository at this point in the history
Signed-off-by: Huy Mai <[email protected]>
  • Loading branch information
mquhuy committed Aug 6, 2024
1 parent a8d421e commit f7c48a2
Showing 1 changed file with 55 additions and 35 deletions.
90 changes: 55 additions & 35 deletions .github/workflows/build-images-action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: build-images-action

on:
push:
branches:
- 'main'
- 'release-*'
tags:
- 'v*'
pull_request
# push:
# branches:
# - 'main'
# - 'release-*'
# tags:
# - 'v*'

permissions: {}

Expand All @@ -20,37 +21,56 @@ jobs:

if: github.repository == 'metal3-io/baremetal-operator'
steps:

- name: Get current date
id: date
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Get image tags
id: image_tags
run: |
image_tags=$(echo "${{ github.ref_name }}" | sed 's/\//_/')
image_tags="${image_tags} ${{ steps.get_name.outputs.name }}_${{ steps.date.outputs.current_date }}_${{ github.sha }}" >> $GITHUB_OUTPUT
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
image_tags="${image_tags} latest" >> $GITHUB_OUTPUT
fi
- name: Echo the image tags
run: echo "${{ steps.image_tags.outputs.image_tags }}"

- name: build bmo image
uses: toptal/jenkins-job-trigger-action@137fff703dd260b52b53d3ba1960396415abc568 # 1.0.2
uses: philips-software/[email protected]
with:
jenkins_url: "https://jenkins.nordix.org/"
jenkins_user: "[email protected]"
jenkins_token: ${{ secrets.JENKINS_TOKEN }}
job_name: "metal3_baremetal-operator_container_image_building"
job_params: |
{
"BUILD_CONTAINER_IMAGE_GIT_REFERENCE": "${{ github.ref }}"
}
job_timeout: "1000"
dockerfile: "./Dockerfile"
image-name: "baremetal-operator"
tags: "${{ steps.image_tags.outputs.image_tags }}"
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: "${{ secrets.REGISTRY_TOKEN }}"
REGISTRY_URL: quay.io/metal3-io
GITHUB_ORGANIZATION: metal3-io
BUILD_CONTAINER_IMAGE_GIT_REFERENCE": "${{ github.ref }}"

- name: build keepalived image
uses: toptal/jenkins-job-trigger-action@137fff703dd260b52b53d3ba1960396415abc568 # 1.0.2
uses: philips-software/[email protected]
with:
jenkins_url: "https://jenkins.nordix.org/"
jenkins_user: "[email protected]"
jenkins_token: ${{ secrets.JENKINS_TOKEN }}
job_name: "metal3_keepalived_container_image_building"
job_params: |
{
"BUILD_CONTAINER_IMAGE_GIT_REFERENCE": "${{ github.ref }}"
}
job_timeout: "1000"
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@4e5fb42d249be6a45a298f3c9543b111b02f7907 # 2.3.0
dockerfile: "./resources/keepalived-docker/Dockerfile"
image-name: "keepalived"
tags: ${{ steps.image_tags.outputs.image_tags }}
env:
SLACK_TITLE: 'GitHub Action Failed in ${{ github.repository }}'
SLACK_COLOR: '#FF0000'
SLACK_MESSAGE: 'The GitHub Action workflow failed for baremetal operator image build.'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: metal3-github-actions-notify
SLACK_USERNAME: metal3-github-actions-notify
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: "${{ secrets.REGISTRY_TOKEN }}"
REGISTRY_URL: quay.io/metal3-io
GITHUB_ORGANIZATION: metal3-io
BUILD_CONTAINER_IMAGE_GIT_REFERENCE": "${{ github.ref }}"

# - name: Slack Notification on Failure
# if: ${{ failure() }}
# uses: rtCamp/action-slack-notify@4e5fb42d249be6a45a298f3c9543b111b02f7907 # 2.3.0
# env:
# SLACK_TITLE: 'GitHub Action Failed in ${{ github.repository }}'
# SLACK_COLOR: '#FF0000'
# SLACK_MESSAGE: 'The GitHub Action workflow failed for baremetal operator image build.'
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# SLACK_CHANNEL: metal3-github-actions-notify
# SLACK_USERNAME: metal3-github-actions-notify

0 comments on commit f7c48a2

Please sign in to comment.