Update chart-releaser.yml #66
This file contains hidden or 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 | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- '*' | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version-file: src/go.mod | |
- name: Cache Go Modules and Build | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
- name: Install yq | |
run: | | |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.43.1/yq_linux_amd64 -O /usr/bin/yq | |
sudo chmod +x /usr/bin/yq | |
- name: Vet | |
run: cd src && go vet ./... | |
- name: Build | |
run: cd src && go build ./... | |
- name: Format check | |
run: | | |
cd src | |
diff=$(gofmt -l $(find . -name '*.go')) | |
if [ -n "$diff" ]; then | |
echo "The following files need formatting:" >&2 | |
echo "$diff" >&2 | |
exit 1 | |
fi | |
- name: Helm Lint | |
run: helm lint manifests | |
- name: Log in to GitHub Container Registry (GHCR) | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Convert Repository Name to Lowercase | |
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Sanitize ref name for image tags | |
run: echo "REF_SLUG=$(echo ${{ github.ref_name }} | tr '/:' '-')" >> $GITHUB_ENV | |
- name: Build and Push Release Docker Image | |
uses: docker/build-push-action@v5 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
context: ./src | |
file: ./src/Dockerfile | |
push: true | |
tags: ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }} | |
platforms: linux/amd64,linux/arm64 | |
release: | |
name: Release Docker Image | |
needs: build | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Log in to GitHub Container Registry (GHCR) | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Convert Repository Name to Lowercase | |
run: echo "REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Pull Release Docker Image | |
run: docker pull ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }} | |
- name: Tag and Push Release Image | |
run: | | |
docker tag ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }} ghcr.io/${{ env.REPO_NAME }}:latest | |
docker push ghcr.io/${{ env.REPO_NAME }}:latest |