diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..735403f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +--- + +on: + push: + pull_request: + +build-latest: + runs-on: [ self-hosted, cluster ] + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v3 + - uses: docker/login-action@v2 + with: + registry: ${{ vars.KRYSTAL_REGISTRY_HOST }} + username: ${{ vars.KRYSTAL_REGISTRY_USERNAME }} + password: ${{ secrets.KRYSTAL_REGISTRY_PASSWORD }} + - uses: docker/setup-buildx-action@v2 + - uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + push: true + tags: registry.k.io/hosting/sonarcloud-github-action:latest + cache-from: type=gha + cache-to: type=gha,mode=max + +build-release: + runs-on: [ self-hosted, cluster ] + if: startsWith(github.ref, 'refs/tags/') + steps: + - uses: actions/checkout@v3 + - uses: docker/login-action@v2 + with: + registry: ${{ vars.KRYSTAL_REGISTRY_HOST }} + username: ${{ vars.KRYSTAL_REGISTRY_USERNAME }} + password: ${{ secrets.KRYSTAL_REGISTRY_PASSWORD }} + - id: version + run: echo "version=$(basename $GITHUB_REF)" >> $GITHUB_OUTPUT + - uses: docker/setup-buildx-action@v2 + - uses: docker/build-push-action@v3 + with: + context: ./ + file: ./Dockerfile + push: true + tags: registry.k.io/hosting/sonarcloud-github-action:${{ steps.version.outputs.version }} + cache-from: type=gha + cache-to: type=gha,mode=max