Nightly Release #1702
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: Nightly Release | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| custom_tag: | |
| description: 'Custom tag (optional, will use "nightly" if not provided)' | |
| required: false | |
| type: string | |
| jobs: | |
| check-date: | |
| runs-on: ubuntu-latest | |
| name: Check latest commit | |
| outputs: | |
| should_run: ${{ steps.check.outputs.should_run }} | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - id: check | |
| run: | | |
| test -n "$(git rev-list --after="24 hours" ${{ github.sha }})" \ | |
| && echo "should_run=true" >>$GITHUB_OUTPUT \ | |
| || echo "should_run=false" >>$GITHUB_OUTPUT | |
| test: | |
| name: Lint and test | |
| needs: check-date | |
| if: ${{ needs.check-date.outputs.should_run == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version-file: go.mod | |
| - name: Lint | |
| uses: golangci/golangci-lint-action@v9 | |
| with: | |
| install-mode: goinstall | |
| version: v2.6.1 | |
| - name: Test | |
| run: go test ./... | |
| build-docker: | |
| name: Build and release Docker image | |
| needs: [check-date, test] | |
| if: ${{ needs.check-date.outputs.should_run == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Docker Buildx | |
| uses: docker/setup-buildx-action@v1 | |
| with: | |
| install: true | |
| version: latest | |
| driver-opts: image=moby/buildkit:master | |
| - name: Login into DockerHub | |
| run: echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
| - name: Login into GitHub Container Registry | |
| run: echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: Generate short hash and set tag | |
| run: | | |
| _short_hash=${{ github.sha }} | |
| echo "SHORT_HASH=${_short_hash:0:7}" >> $GITHUB_ENV | |
| if [ -n "${{ github.event.inputs.custom_tag }}" ]; then | |
| echo "TAG_NAME=${{ github.event.inputs.custom_tag }}" >> $GITHUB_ENV | |
| else | |
| echo "TAG_NAME=nightly" >> $GITHUB_ENV | |
| fi | |
| - name: Build and Push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7 | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:${{ env.SHORT_HASH }} | |
| ghcr.io/${{ github.repository }}:${{ env.TAG_NAME }} | |
| ${{ github.repository }}:${{ env.SHORT_HASH }} | |
| ${{ github.repository }}:${{ env.TAG_NAME }} |