From 470abfbcde6c3b2cf115b173117df6e7aea99ebf Mon Sep 17 00:00:00 2001 From: Vitor Cardoso Date: Wed, 12 Jul 2023 09:30:59 +0100 Subject: [PATCH] Adding the bootstrap image --- .github/bootstrap-image/Dockerfile | 13 ++++++++ .github/workflows/bootstrap-image.yml | 43 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/bootstrap-image/Dockerfile create mode 100644 .github/workflows/bootstrap-image.yml diff --git a/.github/bootstrap-image/Dockerfile b/.github/bootstrap-image/Dockerfile new file mode 100644 index 0000000..6c60796 --- /dev/null +++ b/.github/bootstrap-image/Dockerfile @@ -0,0 +1,13 @@ +FROM docker.repo.orl.eng.hitachivantara.com/jenkins-build/maven/open-jdk/11 + +ARG VERSION_MERGER=1.0.8 +ARG ARTIFACTORY_URL=https://repo.orl.eng.hitachivantara.com/artifactory/pnt-mvn + +RUN curl -L -o version-merger.jar ${ARTIFACTORY_URL}/pentaho/version-merger/${VERSION_MERGER}/version-merger-${VERSION_MERGER}.jar + +RUN curl -fL https://install-cli.jfrog.io | sh + +ARG JQ_VERSION=1.6 +RUN curl -L -o jq-linux64 https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64 && \ + mv jq-linux64 /usr/local/bin/jq && \ + chmod +x /usr/local/bin/jq diff --git a/.github/workflows/bootstrap-image.yml b/.github/workflows/bootstrap-image.yml new file mode 100644 index 0000000..020e019 --- /dev/null +++ b/.github/workflows/bootstrap-image.yml @@ -0,0 +1,43 @@ +name: Build and Push Container Image + +on: + push: + paths: [ .github/bootstrap-image/** ] +env: + ARTIFACTORY: cicd-oci-release-orl.repo.orl.eng.hitachivantara.com + ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }} + ARTIFACTORY_API_KEY: ${{ secrets.ARTIFACTORY_API_KEY }} + IMAGE: ${{ github.repository_owner }}/${{ github.event.repository.name }} +jobs: + + bootstrap-image: + name: CI Image build and push [${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}] + runs-on: [ self-hosted, Linux, k8s ] + steps: + + # sets the image name and tag to something like: /:. + - name: Update image tag + run: | + IMAGE_TAG=$(date +'%Y%m%d').${{ github.run_number }} + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV + echo "IMAGE=${{ env.IMAGE }}:$IMAGE_TAG" >> $GITHUB_ENV + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build + id: build-image + run: docker build -t "${{ env.ARTIFACTORY }}/${{ env.IMAGE }}" -f .github/bootstrap-image/Dockerfile . + + - name: Push to Artifactory + id: push-to-artifactory + run: | + echo "${{ env.ARTIFACTORY_API_KEY }}" | docker login ${{ env.ARTIFACTORY }} --username ${{ env.ARTIFACTORY_USER }} --password-stdin + docker push "${{ env.ARTIFACTORY }}/${{ env.IMAGE }}" + - name: Summary + run: | + echo ":frog: Image pushed!" >> $GITHUB_STEP_SUMMARY + echo "Pull it from '${{ env.ARTIFACTORY }}/${{ env.IMAGE }}'" >> $GITHUB_STEP_SUMMARY + - uses: rickstaa/action-create-tag@v1 + with: + tag: "build-image-${{ env.IMAGE_TAG }}" + message: "${{ env.ARTIFACTORY }}/${{ env.IMAGE }}" \ No newline at end of file