From 8a29e580003cd4e3ac0bbbafe6db89e4f16f572c Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 23 Oct 2022 16:56:22 +0200 Subject: [PATCH] Add CI/CD --- .drone.yml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..9f784b7 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,72 @@ +--- +kind: pipeline +type: docker +name: build-arm + +platform: + os: linux + arch: arm + +workspace: + base: /go + path: src/git.nemunai.re/nemunaire/idfm-api + +steps: +- name: build + image: golang:1-alpine + commands: + - mkdir deploy + - apk --no-cache add build-base git + - go get -v -d + - go vet -v + - go build -v -ldflags '-w -X main.Version="${DRONE_BRANCH}-${DRONE_COMMIT}" -X main.build=${DRONE_BUILD_NUMBER}' -o idfm-api-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} + - ln idfm-api-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} deploy/idfm-api + environment: + CGO_ENABLED: 0 + GOARCH: arm + GOARM: 5 + when: + event: + exclude: + - tag + +- name: build tag + image: golang:1-alpine + commands: + - mkdir deploy + - apk --no-cache add build-base git + - go get -v -d + - go vet -v + - go build -v -ldflags '-w -X main.Version="${DRONE_TAG##v}" -X main.build=${DRONE_BUILD_NUMBER}' -o idfm-api-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} + - ln idfm-api-${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH} deploy/idfm-api + environment: + CGO_ENABLED: 0 + GOARCH: arm + GOARM: 5 + when: + event: + - tag + +- name: deploy + image: appleboy/drone-scp + settings: + tar_tmp_path: /tmp/ + host: ratp.p0m.fr + target: /usr/local/bin/ratp + source: deploy/idfm-api + strip_components: 1 + username: + from_secret: ssh_username + key: + from_secret: deploy_key + port: + from_secret: ssh_port + when: + branch: + - master + +trigger: + event: + - cron + - push + - tag