This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
build(deps): update golang docker tag to v1.21.5 #1964
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: CI | |
on: | |
# allow manual dispatch | |
workflow_dispatch: | |
# always execute docker build when something is pushed to master or release-* branches | |
push: | |
branches: | |
- "master" | |
# in addition, execute for pull requests to those branches | |
pull_request: | |
branches: | |
- "master" | |
- "release-[0-9]*" | |
defaults: | |
run: | |
shell: bash | |
env: | |
VERSION_FILE: "x-release-please-version.json" | |
jobs: | |
############################################################################ | |
# Prepare CI Run (determine version, git sha, datetime, ...) # | |
############################################################################ | |
prepare_ci_run: | |
name: Prepare CI Run | |
uses: keptn/gh-automation/.github/workflows/[email protected] | |
############################################################################ | |
# Unit tests # | |
############################################################################ | |
unit-tests: | |
name: Unit Tests | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out repository | |
uses: actions/[email protected] | |
- name: Unit tests | |
uses: ./.github/actions/unit-tests | |
############################################################################ | |
# Use version of release please if gh ref is a release-please pr branch # | |
############################################################################ | |
verify-next-version: | |
needs: prepare_ci_run | |
name: Verify next version | |
runs-on: ubuntu-20.04 | |
env: | |
VERSION: ${{ needs.prepare_ci_run.outputs.VERSION }} | |
outputs: | |
NEXT-VERSION: ${{ steps.verify-next-version.outputs.NEXT-VERSION }} | |
steps: | |
- name: Checkout repo | |
uses: actions/[email protected] | |
- name: Overwrite version variable from prepare_ci_run in case of a release-please-branch | |
id: verify-next-version | |
run: | | |
echo "Note: GITHUB_REF_HEADS=${GITHUB_HEAD_REF}" | |
if [[ "${GITHUB_HEAD_REF}" == "release-please-"* ]]; then | |
# Release PR: extract version from x-release-please-version.json | |
RELEASEPLEASE_VERSION=$(jq -r '."x-release-please-version"' ${{ env.VERSION_FILE }}) | |
echo "NEXT-VERSION=${RELEASEPLEASE_VERSION}-rc" >> $GITHUB_OUTPUT | |
else | |
echo "NEXT-VERSION=${VERSION}" >> $GITHUB_OUTPUT | |
fi | |
############################################################################ | |
# Build Helm Charts # | |
############################################################################ | |
helm_charts_build: | |
needs: | |
- prepare_ci_run | |
- verify-next-version | |
name: Build Helm Charts | |
runs-on: ubuntu-20.04 | |
env: | |
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
VERSION: ${{ needs.verify-next-version.outputs.NEXT-VERSION }} | |
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | |
steps: | |
- name: Checkout Code | |
uses: actions/[email protected] | |
- name: Load CI Environment from .ci_env | |
id: load_ci_env | |
uses: c-py/action-dotenv-to-setenv@v4 | |
with: | |
env-file: .ci_env | |
- name: Build Helm Chart | |
id: build_helm_chart | |
run: | | |
if [[ "$BRANCH" == "master" ]]; then | |
# use VERSION.DATETIME for the image tag (e.g., nightly build) | |
./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}.${DATETIME}" "${IMAGE}" | |
else | |
# just use VERSION for the image tag | |
./gh-actions-scripts/build_helm_chart.sh "${VERSION}" "${VERSION}" "${IMAGE}" | |
fi | |
- name: Upload Helm Chart as an artifact | |
id: upload_helm_chart | |
uses: actions/upload-artifact@v3 | |
with: | |
name: installer | |
path: installer/*.tgz | |
############################################################################ | |
# Build Docker Image # | |
############################################################################ | |
docker_build: | |
needs: | |
- prepare_ci_run | |
- verify-next-version | |
- unit-tests | |
name: Docker Build | |
runs-on: ubuntu-20.04 | |
env: | |
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
VERSION: ${{ needs.verify-next-version.outputs.NEXT-VERSION }} | |
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | |
steps: | |
- name: Checkout Code | |
uses: actions/[email protected] | |
- name: Load CI Environment from .ci_env | |
id: load_ci_env | |
uses: c-py/action-dotenv-to-setenv@v4 | |
with: | |
env-file: .ci_env | |
- name: Docker Build | |
id: docker_build | |
uses: keptn/gh-automation/.github/actions/[email protected] | |
with: | |
TAGS: | | |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }} | |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}.${{ env.DATETIME }} | |
BUILD_ARGS: | | |
version=${{ env.VERSION }} | |
REGISTRY_USER: ${{ secrets.REGISTRY_USER }} | |
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | |
PUSH: ${{(github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository)}} | |
- id: report_docker_build_to_pr | |
name: Report Docker Build to PR | |
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
recreate: true | |
header: test | |
message: | | |
The following Docker Images have been built: | |
${{ fromJSON(steps.docker_build.outputs.BUILD_METADATA)['image.name'] }} | |
store-output-in-build-config: | |
name: "Store output of last step in build-config.env" | |
needs: | |
- prepare_ci_run | |
- verify-next-version | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Create build config file | |
env: | |
BRANCH: ${{ needs.prepare_ci_run.outputs.BRANCH }} | |
BRANCH_SLUG: ${{ needs.prepare_ci_run.outputs.BRANCH_SLUG }} | |
VERSION: ${{ needs.verify-next-version.outputs.NEXT-VERSION }} | |
DATETIME: ${{ needs.prepare_ci_run.outputs.DATETIME }} | |
GIT_SHA: ${{ needs.prepare_ci_run.outputs.GIT_SHA }} | |
run: | | |
echo "BRANCH=${BRANCH}" >> build-config.env | |
echo "BRANCH_SLUG=${BRANCH_SLUG}" >> build-config.env | |
echo "VERSION=${VERSION}" >> build-config.env | |
echo "DATETIME=${DATETIME}" >> build-config.env | |
echo "GIT_SHA=${GIT_SHA}" >> build-config.env | |
- name: Upload build config as artifact | |
id: upload_build_config | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-config | |
path: build-config.env |