diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ff4d3e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,25 @@ +name: Build + +on: + workflow_call: + inputs: + tags: + type: string + description: The Docker Tags (see docker/metadata-action@v4 for available values) + required: true + +jobs: + build-k6: + runs-on: ubuntu-latest + + steps: + - name: Build/Push + uses: coopTilleuls/action-docker-build-push@v10 + with: + IMAGE_NAME: k6-runner + BUILD_CONTEXT: release + REGISTRY_JSON_KEY: ${{ secrets.GITHUB_TOKEN }} + IMAGE_REPOSITORY: ghcr.io/cooptilleuls + + + diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..da9215c --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,35 @@ +name: CD +on: + push: + branches: + - main + tags: + - '*' + + pull_request: + types: [ opened, reopened, synchronize, labeled ] + +jobs: + remove-deploy-label: + name: Remove deploy label + if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy') + runs-on: ubuntu-latest + steps: + - uses: mondeja/remove-labels-gh-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + labels: | + deploy + + build: + name: Build + if: github.event_name != 'pull_request' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'deploy')) + uses: ./.github/workflows/build.yml + with: + tags: | + type=ref,event=branch + type=ref,event=pr + type=ref,event=tag + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8eca80e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM grafana/xk6:latest as builder +RUN xk6 build --with github.com/grafana/xk6-redis --with github.com/grafana/xk6-output-prometheus-remote + +FROM alpine:3.18 as release +RUN adduser -D -u 12345 -g 12345 k6 +COPY --from=builder /xk6/k6 /usr/bin/k6 +USER k6 +WORKDIR /home/k6 +ENTRYPOINT ["k6"]