Reviewed-on: #5main
parent
2e1267f20b
commit
618157a235
|
@ -0,0 +1,63 @@
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: code.jhot.me/drone-users/drone-builder-image:main
|
||||||
|
volumes:
|
||||||
|
- name: docker
|
||||||
|
path: /var/lib/docker
|
||||||
|
- name: dockersocket
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- task setup-buildx BUILDER_NAME=builder${DRONE_COMMIT_SHA}${DRONE_BUILD_NUMBER}
|
||||||
|
- tag=$${DRONE_TAG:-$DRONE_BRANCH} # set tag to tag name (if applicable) or branch name
|
||||||
|
- task build TAG=$tag # build the docker image
|
||||||
|
- name: publish tag
|
||||||
|
image: code.jhot.me/drone-users/drone-builder-image:main
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
environment:
|
||||||
|
PASSOWRD:
|
||||||
|
from_secret: FORGEJO_PASSWORD
|
||||||
|
volumes:
|
||||||
|
- name: docker
|
||||||
|
path: /var/lib/docker
|
||||||
|
- name: dockersocket
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker login -u drone -p $PASSWORD
|
||||||
|
- tag=$${DRONE_TAG:-$DRONE_BRANCH} # set tag to tag name (if applicable) or branch name
|
||||||
|
- task push TAG=$tag
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- tag
|
||||||
|
- name: publish main
|
||||||
|
image: code.jhot.me/drone-users/drone-builder-image:main
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
environment:
|
||||||
|
PASSOWRD:
|
||||||
|
from_secret: FORGEJO_PASSWORD
|
||||||
|
volumes:
|
||||||
|
- name: docker
|
||||||
|
path: /var/lib/docker
|
||||||
|
- name: dockersocket
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
commands:
|
||||||
|
- docker login -u drone -p $PASSWORD
|
||||||
|
- task push TAG=main
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: dockersocket
|
||||||
|
host:
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
- name: docker
|
||||||
|
temp: {}
|
||||||
|
|
||||||
|
image_pull_secrets:
|
||||||
|
- dockerconfig
|
|
@ -1,49 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
tags:
|
|
||||||
- v[0-9]*
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_test:
|
|
||||||
runs_on: docker
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://code.forgejo.org/actions/checkout@v3
|
|
||||||
- name: Dependenies
|
|
||||||
run: |
|
|
||||||
curl -fsSL https://get.docker.com -o get-docker.sh
|
|
||||||
sh ./get-docker.sh
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://github.com/docker/setup-buildx-action@v2.10.0
|
|
||||||
with:
|
|
||||||
endpoint: tcp://192.168.0.5:2375
|
|
||||||
- name: Docker metadata
|
|
||||||
id: meta
|
|
||||||
uses: https://github.com/docker/metadata-action@v4.6.0
|
|
||||||
with:
|
|
||||||
images: code.jhot.me/jhot/docker-s3-backup
|
|
||||||
tags: |
|
|
||||||
type=ref,event=branch
|
|
||||||
type=ref,event=pr
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
- name: Login to DockerHub
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: https://github.com/docker/login-action@v2.2.0
|
|
||||||
with:
|
|
||||||
registry: code.jhot.me
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v4.2.1
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
16
Taskfile.yml
16
Taskfile.yml
|
@ -4,17 +4,25 @@ vars:
|
||||||
NAME: code.jhot.me/jhot/docker-s3-backup
|
NAME: code.jhot.me/jhot/docker-s3-backup
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
default:
|
|
||||||
vars:
|
|
||||||
TAG: latest
|
|
||||||
build:
|
build:
|
||||||
cmds:
|
cmds:
|
||||||
- docker buildx build --platform linux/amd64,linux/arm64 -t "{{.NAME}}:{{.TAG}}" .
|
- docker buildx build --platform linux/amd64,linux/arm64 -t "{{.NAME}}:{{.TAG}}" .
|
||||||
|
vars:
|
||||||
|
TAG: '{{.TAG | default "latest"}}'
|
||||||
push:
|
push:
|
||||||
cmds:
|
cmds:
|
||||||
- docker push "{{.NAME}}:{{.TAG}}"
|
- docker buildx build --push --platform linux/amd64,linux/arm64 -t "{{.NAME}}:{{.TAG}}" .
|
||||||
|
vars:
|
||||||
|
TAG: '{{.TAG | default "latest"}}'
|
||||||
tag:
|
tag:
|
||||||
prompt: This will push a git tag and docker image versioned {{.TAG}}... Do you want to continue?
|
prompt: This will push a git tag and docker image versioned {{.TAG}}... Do you want to continue?
|
||||||
cmds:
|
cmds:
|
||||||
- git tag "{{.TAG}}"
|
- git tag "{{.TAG}}"
|
||||||
- git push origin "{{.TAG}}"
|
- git push origin "{{.TAG}}"
|
||||||
|
vars:
|
||||||
|
TAG: '{{.TAG | default "latest"}}'
|
||||||
|
setup-buildx:
|
||||||
|
cmds:
|
||||||
|
- docker buildx create --name {{.BUILDER_NAME}} --use
|
||||||
|
vars:
|
||||||
|
BUILDER_NAME: '{{.BUILDER_NAME | default "mybuilder"}}'
|
||||||
|
|
Loading…
Reference in New Issue