build: updating gitignore and dockerignore #34
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/CD | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
calculate-version: | |
if: > | |
contains(github.event.head_commit.message, 'release') | |
name: Calculate Version | |
runs-on: ubuntu-latest | |
outputs: | |
semVer: ${{ steps.gitversion.outputs.semVer }} | |
steps: | |
# gitversion/execute step omitted for brevity | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: '5.x' | |
includePrerelease: true | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
with: | |
configFilePath: 'GitVersion.yml' | |
useConfigFile: true | |
build: | |
if: > | |
contains(github.event.head_commit.message, 'release') | |
name: Build | |
runs-on: ubuntu-latest | |
needs: calculate-version | |
env: | |
SEMVER: ${{ needs.calculate-version.outputs.semVer }} | |
outputs: | |
semVer: ${{ needs.calculate-version.outputs.semVer }} | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push the Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: | | |
duratm/pycount-backend:latest | |
duratm/pycount-backend:${{ env.SEMVER }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
update-manifests: | |
if: > | |
contains(github.event.head_commit.message, 'release') | |
name: Update Manifests | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: master | |
- run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "[email protected]" | |
git merge origin/develop --ff-only | |
- name: Install yq | |
uses: mikefarah/yq@v4 | |
- name: Update manifests | |
run: | | |
yq eval -i '.spec.template.spec.containers[0].image = "duratm/pycount-backend:${{ needs.build.outputs.semVer }}"' kubernetes/backend/pycount-backend-deploy.yaml | |
- name: Commit and push changes | |
run: | | |
git add . | |
git commit -m "Update manifests to version ${{ needs.build.outputs.semVer }}" | |
git push |