feat(ci): kustomizeを使うように #52
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: Publish Docker image | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
permissions: | |
packages: write | |
contents: write | |
jobs: | |
publish_image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: setup kustomize | |
uses: syntaqx/setup-kustomize@v1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- uses: docker/metadata-action@v4 | |
id: meta | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=sha | |
type=semver,pattern={{version}} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
fetch-depth: 10 | |
- name: kustomize | |
run: | | |
short_sha=$(git rev-parse --short HEAD) | |
cd k8s | |
kustomize edit set image ghcr.io/akarinext/www.akarinext.org=ghcr.io/akarinext/www.akarinext.org:sha-$short_sha | |
git config --global user.name "akarinext" | |
git config --global user.email "[email protected]" | |
git checkout -b auto-update-kustomization | |
git add kustomization.yaml | |
git commit -m "chore: update kustomization.yaml" | |
git push origin auto-update-kustomization |