replace circleci with github workflows
This commit is contained in:
parent
cea5e8f332
commit
ad67bce5a6
|
@ -1,57 +0,0 @@
|
||||||
version: 2
|
|
||||||
jobs:
|
|
||||||
build_latest:
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.17
|
|
||||||
working_directory: ~/twhelpcron
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- setup_remote_docker
|
|
||||||
# start proprietary DB using private Docker image
|
|
||||||
# with credentials stored in the UI
|
|
||||||
- run: |
|
|
||||||
docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
|
|
||||||
# build the cron image
|
|
||||||
- run: docker build -f cmd/cron/Dockerfile -t $DOCKER_LOGIN/twhelp-cron:latest .
|
|
||||||
# build the data updater image
|
|
||||||
- run: docker build -f cmd/dataupdater/Dockerfile -t $DOCKER_LOGIN/twhelp-dataupdater:latest .
|
|
||||||
# deploy the images
|
|
||||||
- run: docker push $DOCKER_LOGIN/twhelp-cron:latest
|
|
||||||
- run: docker push $DOCKER_LOGIN/twhelp-dataupdater:latest
|
|
||||||
build_version:
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.17
|
|
||||||
working_directory: ~/twhelpcron
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- setup_remote_docker
|
|
||||||
# start proprietary DB using private Docker image
|
|
||||||
# with credentials stored in the UI
|
|
||||||
- run: |
|
|
||||||
docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
|
|
||||||
# build the cron image
|
|
||||||
- run: docker build -f cmd/cron/Dockerfile -t $DOCKER_LOGIN/twhelp-cron:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//') .
|
|
||||||
# build the data updater image
|
|
||||||
- run: docker build -f cmd/dataupdater/Dockerfile -t $DOCKER_LOGIN/twhelp-dataupdater:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//') .
|
|
||||||
# deploy the images
|
|
||||||
- run: docker push $DOCKER_LOGIN/twhelp-cron:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//')
|
|
||||||
- run: docker push $DOCKER_LOGIN/twhelp-dataupdater:$(echo $CIRCLE_TAG | sed -r 's/^.{1}//')
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
deploy_latest:
|
|
||||||
jobs:
|
|
||||||
- build_latest:
|
|
||||||
context: TWHelp
|
|
||||||
filters:
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
deploy_version:
|
|
||||||
jobs:
|
|
||||||
- build_version:
|
|
||||||
context: TWHelp
|
|
||||||
filters:
|
|
||||||
tags:
|
|
||||||
only: /^v.*/
|
|
||||||
branches:
|
|
||||||
ignore: /.*/
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
name: Build and push to registry
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
name: Push Docker image to Docker Hub
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Get the version
|
||||||
|
id: get_version
|
||||||
|
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.REGISTRY_LOGIN }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Push dataupdater to Docker Hub
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
tags: |
|
||||||
|
${{ secrets.REGISTRY_NAME }}/twhelp-dataupdater:latest
|
||||||
|
${{ secrets.REGISTRY_NAME }}/twhelp-dataupdater:${{ steps.get_version.outputs.VERSION }}
|
||||||
|
file: ./build/dataupdater/Dockerfile
|
||||||
|
push: true
|
||||||
|
|
||||||
|
- name: Push cron to Docker Hub
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
build-args: |
|
||||||
|
VERSION=${{ steps.get_version.outputs.VERSION }}
|
||||||
|
tags: |
|
||||||
|
${{ secrets.REGISTRY_NAME }}/twhelp-cron:latest
|
||||||
|
${{ secrets.REGISTRY_NAME }}/twhelp-cron:${{ steps.get_version.outputs.VERSION }}
|
||||||
|
file: ./build/cron/Dockerfile
|
||||||
|
push: true
|
|
@ -17,7 +17,7 @@ RUN go build -o twcron ./cmd/cron
|
||||||
######## Start a new stage from scratch #######
|
######## Start a new stage from scratch #######
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
|
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
|
@ -27,6 +27,4 @@ COPY --from=builder /app/twcron .
|
||||||
ENV APP_MODE=production
|
ENV APP_MODE=production
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN apk add --no-cache tzdata
|
|
||||||
|
|
||||||
CMD ./twcron
|
CMD ./twcron
|
|
@ -17,7 +17,7 @@ RUN go build -o twdataupdater ./cmd/dataupdater
|
||||||
######## Start a new stage from scratch #######
|
######## Start a new stage from scratch #######
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
RUN apk --no-cache add ca-certificates
|
RUN apk --no-cache add ca-certificates tzdata
|
||||||
|
|
||||||
WORKDIR /root/
|
WORKDIR /root/
|
||||||
|
|
||||||
|
@ -27,6 +27,4 @@ COPY --from=builder /app/twdataupdater .
|
||||||
ENV APP_MODE=production
|
ENV APP_MODE=production
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
RUN apk add --no-cache tzdata
|
|
||||||
|
|
||||||
CMD ./twdataupdater
|
CMD ./twdataupdater
|
Reference in New Issue