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 029ab25
Showing 1 changed file with 71 additions and 35 deletions.
106 changes: 71 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,72 @@ jobs:

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

- name: Get branch or tag name
id: get_name
run: |
ref=${{ github.ref }}
if [[ "$ref" == refs/heads/* ]]; then
echo "name=${ref#refs/heads/}" >> $GITHUB_OUTPUT
elif [[ "$ref" == refs/tags/* ]]; then
echo "name=${ref#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "name=$ref" >> $GITHUB_OUTPUT
fi
- name: Get short SHA
id: get_sha
run: echo "sha=`git rev-parse --short ${{ github.sha }}`" >> $GITHUB_OUTPUT

- 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 "${{ steps.get_name.outputs.name }}" | sed 's/\//_/')
image_tags="${image_tags} ${{ steps.get_name.outputs.name }}_${{ steps.date.outputs.current_date }}_${{ steps.get_sha.outputs.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 029ab25

Please sign in to comment.