Merge pull request #1 from victormilk/dev #8
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: Workflow | |
on: | |
push: | |
branches: [ "main", "dev" ] | |
jobs: | |
build: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
image: | |
name: Image | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: login to docker hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: build image and push to docker hub | |
uses: docker/build-push-action@v4 | |
with: | |
push: true | |
tags: | | |
victormilk/walterbob:latest | |
victormilk/walterbob:${{ github.sha }} | |
deploy: | |
name: Deploy to Kubernetes | |
needs: image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout k8s repository | |
uses: actions/checkout@v3 | |
with: | |
repository: victormilk/walterbob-k8s | |
ref: ${{ github.ref }} | |
token: ${{ secrets.PAT }} | |
- name: Update tag | |
run: | | |
sed -i "s|newTag:.*|newTag: ${{ github.sha }}|g" kustomization.yaml | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git add . | |
git commit -m "Update image tag to ${{ github.sha }}" | |
git push |