diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 0b0c3f4f..00000000 --- a/.drone.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- -kind: pipeline -name: amd64 - -platform: - os: linux - arch: amd64 - -steps: - - name: build - image: rancher/dapper:v0.6.0 - commands: - - dapper ci - volumes: - - name: docker - path: /var/run/docker.sock - - - name: docker-publish-master - image: plugins/docker - settings: - build_args: - - ARCH=amd64 - - VERSION=${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}-head - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "rancher/harvester-pcidevices" - tag: ${DRONE_BRANCH}-head - username: - from_secret: docker_username - when: - ref: - include: - - "refs/heads/master" - - "refs/heads/release/v*" - event: - - push - - - name: docker-publish - image: plugins/docker - settings: - dockerfile: package/Dockerfile - password: - from_secret: docker_password - repo: "rancher/harvester-pcidevices" - tag: "${DRONE_TAG}" - username: - from_secret: docker_username - when: - instance: - - drone-publish.rancher.io - ref: - - refs/head/master - - refs/tags/* - event: - - tag - -volumes: - - name: docker - host: - path: /var/run/docker.sock diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml new file mode 100644 index 00000000..97e7ab3d --- /dev/null +++ b/.github/workflows/master.yml @@ -0,0 +1,15 @@ +name: Master Build and Publish + +on: + push: + branches: + - master + - release/v* + +jobs: + build-master: + uses: ./.github/workflows/template-build.yml + with: + release-tag-name: ${{ github.ref_name }}-head + push: true + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..7d600209 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,12 @@ +name: Pull Request Build + +on: + pull_request: + +jobs: + build-pr: + uses: ./.github/workflows/template-build.yml + with: + release-tag-name: pull-${{ github.event.number }} + push: false + secrets: inherit diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 00000000..81a7ec08 --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,14 @@ +name: Tag Build and Publish + +on: + push: + tags: + - v* + +jobs: + build-tag: + uses: ./.github/workflows/template-build.yml + with: + release-tag-name: ${{ github.ref_name }} + push: true + secrets: inherit diff --git a/.github/workflows/template-build.yml b/.github/workflows/template-build.yml new file mode 100644 index 00000000..dc8d4146 --- /dev/null +++ b/.github/workflows/template-build.yml @@ -0,0 +1,57 @@ +on: + workflow_call: + inputs: + release-tag-name: + required: true + type: string + push: + required: true + type: boolean +env: + imageName: "rancher/harvester-pcidevices" + +jobs: + dapper-build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Run dapper + run: make ci + + - name: Read some Secrets + uses: rancher-eio/read-vault-secrets@main + if: ${{ inputs.push == true }} + with: + secrets: | + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials username | DOCKER_USERNAME ; + secret/data/github/repo/${{ github.repository }}/dockerhub/rancher/credentials password | DOCKER_PASSWORD + + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: ${{ inputs.push == true }} + with: + username: ${{ env.DOCKER_USERNAME }} + password: ${{ env.DOCKER_PASSWORD }} + + - name: Docker Build + uses: docker/build-push-action@v5 + with: + provenance: false + context: . + platforms: linux/amd64,linux/arm64 + file: package/Dockerfile + push: ${{ inputs.push }} + tags: ${{env.imageName}}:${{ inputs.release-tag-name }} + build-args: | + VERSION=${{ github.ref_name }}-${{ github.sha }}-head \ No newline at end of file diff --git a/scripts/validate b/scripts/validate index 35ff2022..c0dff6b9 100755 --- a/scripts/validate +++ b/scripts/validate @@ -15,5 +15,5 @@ if [[ -z "$(command -v golangci-lint)" ]]; then fi echo "Running: golangci-lint run" -golangci-lint run +golangci-lint run --timeout 10m