diff --git a/.github/actions/build-docker/action.yaml b/.github/actions/build-docker/action.yaml index 367f2e9..f5112d3 100644 --- a/.github/actions/build-docker/action.yaml +++ b/.github/actions/build-docker/action.yaml @@ -17,6 +17,10 @@ inputs: sha: description: "Git SHA" required: true + push: + description: "Push Docker" + required: false + default: "false" outputs: digest: description: "Docker Digest" @@ -33,14 +37,14 @@ runs: tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern={{version}} + type=semver,pattern=v{{version}} type=sha type=raw,value=${{inputs.branch}}-${{inputs.sha}}-${{ inputs.ts }} - name: Build and push id: docker_build uses: docker/build-push-action@v4 with: - push: ${{ github.ref == 'refs/heads/main' }} + push: ${{ inputs.push }} network: host tags: ${{ steps.docker_meta.outputs.tags }} target: ${{ inputs.docker-target }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 69e6b94..2f06909 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,8 +4,6 @@ on: push: branches: - 'main' - tags: - - 'v*' pull_request: branches: - 'main' @@ -52,6 +50,7 @@ jobs: branch: ${{ steps.get_vars.outputs.branch }} sha: ${{ steps.get_vars.outputs.sha }} ts: ${{ steps.get_vars.outputs.ts }} + push: ${{ github.ref == 'refs/heads/main' }} - name: Build Main DB migrations uses: ./.github/actions/build-docker with: @@ -59,6 +58,7 @@ jobs: branch: ${{ steps.get_vars.outputs.branch }} sha: ${{ steps.get_vars.outputs.sha }} ts: ${{ steps.get_vars.outputs.ts }} + push: ${{ github.ref == 'refs/heads/main' }} - name: Build Stats DB migrations uses: ./.github/actions/build-docker with: @@ -66,3 +66,4 @@ jobs: branch: ${{ steps.get_vars.outputs.branch }} sha: ${{ steps.get_vars.outputs.sha }} ts: ${{ steps.get_vars.outputs.ts }} + push: ${{ github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/tags.yaml b/.github/workflows/tags.yaml new file mode 100644 index 0000000..4c70ab8 --- /dev/null +++ b/.github/workflows/tags.yaml @@ -0,0 +1,66 @@ +name: CI + +on: + push: + tags: + - 'v*' + +jobs: + test: + runs-on: ubuntu-20.04 + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.19 + - name: Build + run: go build -v ./... + - name: Test + run: go test -v ./... + build: + runs-on: ubuntu-20.04 + needs: test + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Get Vars + id: get_vars + run: | + echo "ts=$(date +%s)" >> $GITHUB_OUTPUT + echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT + - name: Build Kannon + uses: ./.github/actions/build-docker + with: + docker-target: kannon + branch: ${{ steps.get_vars.outputs.branch }} + sha: ${{ steps.get_vars.outputs.sha }} + ts: ${{ steps.get_vars.outputs.ts }} + push: true + - name: Build Main DB migrations + uses: ./.github/actions/build-docker + with: + docker-target: migrator-db + branch: ${{ steps.get_vars.outputs.branch }} + sha: ${{ steps.get_vars.outputs.sha }} + ts: ${{ steps.get_vars.outputs.ts }} + push: true + - name: Build Stats DB migrations + uses: ./.github/actions/build-docker + with: + docker-target: migrator-stats + branch: ${{ steps.get_vars.outputs.branch }} + sha: ${{ steps.get_vars.outputs.sha }} + ts: ${{ steps.get_vars.outputs.ts }} + push: true