✨ Make the webhook not stomp on container restartPolicy #49
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: main | |
on: | |
push: | |
tags: | |
- v* | |
branches: | |
- main | |
pull_request: | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20 | |
- uses: actions/checkout@v3 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: latest | |
args: --timeout=300s | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
# TODO Set up Kind for integration tests. | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: 1.20 | |
- name: Install Kubebuilder | |
id: install-kubebuilder | |
run: | | |
os=$(go env GOOS) | |
arch=$(go env GOARCH) | |
version=1.29.3 | |
curl -L https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${version}-${os}-${arch}.tar.gz | tar -xz -C /tmp/ | |
sudo mv /tmp/kubebuilder /usr/local/kubebuilder | |
- run: make test | |
build: | |
name: Container Build | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
- lint | |
if: github.event_name != 'pull_request' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Docker Prep | |
id: prep | |
run: | | |
DOCKER_IMAGE="$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" | |
VERSION=edge | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
elif [[ $GITHUB_REF == refs/heads/* ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
elif [[ $GITHUB_REF == refs/pull/* ]]; then | |
VERSION=pr-${{ github.event.number }} | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Github Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GHCR_PAT }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ steps.prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.created=${{ steps.prep.outputs.created }} | |
org.opencontainers.image.revision=${{ github.sha }} |