From c42acd585d4b30cd445e2ac6b3f1e9f5c5a2e4c2 Mon Sep 17 00:00:00 2001 From: To-om Date: Thu, 7 Mar 2024 10:36:25 +0100 Subject: [PATCH] ci: setup actions --- .drone.yml | 47 ---------------------------- .github/workflows/build.yaml | 60 ++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 47 deletions(-) delete mode 100644 .drone.yml create mode 100644 .github/workflows/build.yaml diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 60070a9..0000000 --- a/.drone.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -kind: pipeline -name: default -type: docker - -steps: - - name: build & push image on Harbor - image: plugins/docker - settings: - username: {from_secret: harbor_username} - password: {from_secret: harbor_password} - repo: {from_secret: harbor_repo} - registry: {from_secret: harbor_registry} - when: - branch: - - master - - - name: build & push image on DockerHub - image: plugins/docker - settings: - username: {from_secret: docker_username} - password: {from_secret: docker_password} - repo: {from_secret: docker_repo} - when: - branch: - - master - - - name: send message - image: thehiveproject/drone_keybase - settings: - username: {from_secret: keybase_username} - paperkey: {from_secret: keybase_paperkey} - channel: {from_secret: keybase_channel} - commands: - - | - keybase oneshot -u "$PLUGIN_USERNAME" --paperkey "$PLUGIN_PAPERKEY" - URL="$DRONE_SYSTEM_PROTO://$DRONE_SYSTEM_HOST/$DRONE_REPO/$DRONE_BUILD_NUMBER" - if [ $DRONE_BUILD_STATUS = "success" ] - then - keybase chat send "$PLUGIN_CHANNEL" ":white_check_mark: $DRONE_REPO: build succeeded $URL" - else - keybase chat send "$PLUGIN_CHANNEL" ":x: $DRONE_REPO: build failed $URL" - fi - when: - status: - - success - - failure diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..da68f17 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,60 @@ +name: build + +on: + push: + branches: + - master + schedule: + - cron: 30 22 1 * * + +jobs: + build_image: + name: Build docker image + runs-on: [ ubuntu-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: | + thehiveproject/doc-builder + ${{ secrets.harbor_registry }}/thehiveproject/doc-builder + tags: | + type=raw,value=latest,enable={{ is_default_branch }} + type=raw,value={{ date 'YYYYMMDD' }} + type=sha + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.docker_username }} + password: ${{ secrets.docker_password }} + + - name: Login to Harbor + uses: docker/login-action@v2 + with: + registry: ${{ secrets.harbor_registry }} + username: ${{ secrets.harbor_username }} + password: ${{ secrets.harbor_password }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Slack notification + if: always() + uses: act10ns/slack@v2 + with: + webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }} + status: ${{ job.status }} \ No newline at end of file