CI Feature Branch #25
Workflow file for this run
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 Feature Branch | |
on: | |
workflow_dispatch: {} | |
push: | |
branches: | |
- feature/* | |
paths: | |
- "src/**" | |
- "Dockerfile" | |
env: | |
HELM_DIR: "chart" | |
jobs: | |
docker: | |
name: docker build and push | |
uses: btungut/devops/.github/workflows/workflow-docker-build-push.yml@master | |
with: | |
runs-on: ubuntu-latest | |
app-name: github-runner-on-kubernetes | |
build-docker-context-path: src | |
build-docker-file-path: Dockerfile | |
docker-server: ${{ vars.DOCKER_SERVER }} | |
docker-username: ${{ vars.DOCKER_USERNAME }} | |
docker-repository: ${{ vars.DOCKER_REPOSITORY }} | |
secrets: | |
docker-password: ${{ secrets.DOCKER_PASSWORD }} | |
helm: | |
runs-on: ubuntu-latest | |
needs: docker | |
if: success() | |
env: | |
GIT_COMMIT_ID: ${{ needs.docker.outputs.GIT_COMMIT_ID }} | |
REV_UNIQUE: ${{ needs.docker.outputs.REV_UNIQUE }} | |
GIT_COMMIT_MSG: ${{ needs.docker.outputs.GIT_COMMIT_MSG }} | |
DOCKER_IMAGE: ${{ needs.docker.outputs.DOCKER_IMAGE }} | |
DOCKER_TAG: ${{ needs.docker.outputs.DOCKER_TAG }} | |
steps: | |
- uses: btungut/devops/.github/actions/common@master | |
id: common-vars | |
- uses: btungut/devops/.github/actions/git-checkout@master | |
with: | |
gitToken: ${{ secrets.GITHUB_TOKEN }} | |
- name: validate helm chart | |
shell: bash | |
run: | | |
set -euo pipefail | |
[[ -d $HELM_DIR ]] || { echo "helm chart directory not found"; exit 1; } | |
cd $HELM_DIR | |
[[ -f Chart.yaml ]] || { echo "Chart.yaml not found"; exit 1; } | |
[[ -f values.yaml ]] || { echo "values.yaml not found"; exit 1; } | |
echo "Chart.yaml and values.yaml found" | |
echo "helm dependency update is running..." | |
helm dependency update . | |
working-directory: app | |
- name: helm details | |
shell: bash | |
run: | | |
set -euo pipefail | |
cd $HELM_DIR | |
tree . | |
CHART_VERSION_WITHOUT_BETA=$(yq '.version' Chart.yaml | cut -f1 -d"-") | |
NEW_CHART_VERSION="${CHART_VERSION_WITHOUT_BETA}-${{ env.DOCKER_TAG}}" | |
echo "NEW_CHART_VERSION=$NEW_CHART_VERSION" >> $GITHUB_ENV | |
echo "NEW_CHART_VERSION=$NEW_CHART_VERSION" >> $GITHUB_OUTPUT | |
echo "NEW_CHART_VERSION=$NEW_CHART_VERSION" | |
MODIFY_YAML_SCRIPT="${{ github.workspace }}/devops/scripts/modify-yaml.sh" | |
chmod +x $MODIFY_YAML_SCRIPT | |
$MODIFY_YAML_SCRIPT "Chart.yaml" ".version" "$NEW_CHART_VERSION" | |
$MODIFY_YAML_SCRIPT "Chart.yaml" ".appVersion" "${REV_UNIQUE}-$GIT_COMMIT_ID" | |
$MODIFY_YAML_SCRIPT "Chart.yaml" ".description" "$GIT_COMMIT_MSG" | |
$MODIFY_YAML_SCRIPT "Chart.yaml" '.annotations["github.com/hash"]' "$GIT_COMMIT_ID" | |
$MODIFY_YAML_SCRIPT "Chart.yaml" '.annotations["github.com/run-url"]' "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
echo -e "\n\n--- Chart.yaml ---" | |
cat Chart.yaml | |
echo "--- Chart.yaml ---" | |
$MODIFY_YAML_SCRIPT "values.yaml" ".image.repository" "$DOCKER_IMAGE" | |
$MODIFY_YAML_SCRIPT "values.yaml" ".image.tag" "$DOCKER_TAG" "$GIT_COMMIT_ID" | |
echo -e "\n\n--- values.yaml ---" | |
cat values.yaml | |
echo "--- values.yaml ---" | |
working-directory: app | |
results: | |
name: test results | |
needs: | |
- docker | |
- helm | |
if: success() | |
runs-on: ubuntu-latest | |
steps: | |
- name: test | |
run: | | |
set -euo pipefail | |
echo "GIT_COMMIT_ID = ${{ needs.docker.outputs.GIT_COMMIT_ID }}" | |
echo "GIT_COMMIT_MESSAGE = ${{ needs.docker.outputs.GIT_COMMIT_MSG }}" | |
echo "GIT_COMITTER = ${{ needs.docker.outputs.GIT_COMITTER }}" | |
echo "GIT_COMMIT_DATE = ${{ needs.docker.outputs.GIT_COMMIT_DATE }}" | |
echo "DOCKER_IMAGE = ${{ needs.docker.outputs.DOCKER_IMAGE }}" |