kyusooK is out building GitHub Actions #5
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: github-action | |
run-name: ${{ github.actor }} is out building GitHub Actions | |
on: | |
push: | |
# Pattern matched against refs/tags | |
tags: | |
- '**' | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Create and use multi-platform builder | |
run: | | |
docker buildx create --use --name builder --platform linux/amd64,linux/arm64 | |
docker buildx inspect --bootstrap | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Maven Projects | |
run: | | |
mvn clean package -f ./accident/pom.xml | |
mvn clean package -f ./assessment/pom.xml | |
mvn clean package -f ./compensation/pom.xml | |
mvn clean package -f ./statistics/pom.xml | |
mvn clean package -f ./notification/pom.xml | |
- name: Set lowercase names to use in tags | |
run: | | |
echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
echo "REF_NAME=$(echo ${{ github.ref_name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Docker Build and push for Accident | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./accident | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_NAME }}/accident:latest | |
ghcr.io/${{ env.REPO_NAME }}/accident:${{ env.REF_NAME }} | |
- name: Docker Build and push for Assessment | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./assessment | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_NAME }}/assessment:latest | |
ghcr.io/${{ env.REPO_NAME }}/assessment:${{ env.REF_NAME }} | |
- name: Docker Build and push for Compensation | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./compensation | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_NAME }}/compensation:latest | |
ghcr.io/${{ env.REPO_NAME }}/compensation:${{ env.REF_NAME }} | |
- name: Docker Build and push for Statistics | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./statistics | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_NAME }}/statistics:latest | |
ghcr.io/${{ env.REPO_NAME }}/statistics:${{ env.REF_NAME }} | |
- name: Docker Build and push for Notification | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./notification | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: | | |
ghcr.io/${{ env.REPO_NAME }}/notification:latest | |
ghcr.io/${{ env.REPO_NAME }}/notification:${{ env.REF_NAME }} | |
- name: Update Kubernetes manifests | |
run: | | |
sed -i '/name: "accident"/{N;s|image: "ghcr.io/[^"]*"|image: "ghcr.io/${{ env.REPO_NAME }}/accident:${{ env.REF_NAME }}"|}' ./kubernetes/template/template.yml | |
sed -i '/name: "assessment"/{N;s|image: "ghcr.io/[^"]*"|image: "ghcr.io/${{ env.REPO_NAME }}/assessment:${{ env.REF_NAME }}"|}' ./kubernetes/template/template.yml | |
sed -i '/name: "compensation"/{N;s|image: "ghcr.io/[^"]*"|image: "ghcr.io/${{ env.REPO_NAME }}/compensation:${{ env.REF_NAME }}"|}' ./kubernetes/template/template.yml | |
sed -i '/name: "statistics"/{N;s|image: "ghcr.io/[^"]*"|image: "ghcr.io/${{ env.REPO_NAME }}/statistics:${{ env.REF_NAME }}"|}' ./kubernetes/template/template.yml | |
sed -i '/name: "notification"/{N;s|image: "ghcr.io/[^"]*"|image: "ghcr.io/${{ env.REPO_NAME }}/notification:${{ env.REF_NAME }}"|}' ./kubernetes/template/template.yml | |
git config --global user.email ${{ github.actor }}@users.noreply.github.com | |
git config --global user.name "${{ github.actor }}" | |
git add ./kubernetes/template.yml | |
git commit -m "Update image tag to ${{ env.REF_NAME }}" | |
git push origin HEAD:main | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |