mirror of
https://github.com/drone/drone-git.git
synced 2026-06-16 14:50:26 +08:00
Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3363275f2a | |||
| c23e93a782 | |||
| bae18c8c71 | |||
| c41dfd51c5 | |||
| ad9d687dbe | |||
| 39d233b3d9 | |||
| d2b4c922fd | |||
| c40d9ffccc | |||
| f03006262c | |||
| 8070857203 | |||
| 3ccd78325a | |||
| 806bc25846 | |||
| 3d2cbbe9ba | |||
| f7b49aaf9e | |||
| be769618aa | |||
| 487521c8bc | |||
| 79700f47fe | |||
| 41c2120a63 | |||
| 9a0e8cc9d6 | |||
| 16f4dd8829 | |||
| e2f563e07f | |||
| 56e4928d73 | |||
| 70fe2c5f68 | |||
| f006eebba3 | |||
| 937b910001 | |||
| 6647ff2107 | |||
| a0b9eebc4f | |||
| e82207b591 | |||
| 21eadbab5b | |||
| b3e3302ecf | |||
| d2d831e671 | |||
| 3fece4c3ef | |||
| 3f12c6de5c | |||
| 6950125511 | |||
| e8ff70dc6a | |||
| 4148c5c886 | |||
| fc019e513c | |||
| d0bca2a1f7 | |||
| dd96a5a670 | |||
| 1cc29870a1 | |||
| e4396e7c26 | |||
| a5164ab012 | |||
| 1af95e7756 | |||
| 570050ebdd | |||
| da8b0f06c8 | |||
| 3aa6fca781 | |||
| 14ed083e1c | |||
| 5f949df9c8 | |||
| 47ba7912a0 | |||
| 8f0278c190 | |||
| 7eaff99357 | |||
| 5b0a12bcb3 | |||
| caad046d7a | |||
| 5159feae9f | |||
| c2b692bf44 | |||
| a01800911c | |||
| ad2dad7b8a | |||
| dddd99c40a | |||
| a2c9b60089 | |||
| a818535cfc | |||
| 584c0ee731 | |||
| 68c60db9d5 | |||
| 214a9d2492 | |||
| 059b7b18b0 | |||
| 5f6bea6871 | |||
| b7b05f526c | |||
| 1ef9ff7e4d | |||
| 3174a3cfd3 | |||
| 6dca8731a7 | |||
| 1b0a44afc1 | |||
| 1fc5fded5a | |||
| e7468f9a19 | |||
| 419d29331d | |||
| 7bb19442db | |||
| f290e93029 | |||
| 16d4b8019f | |||
| 7a6564cc28 | |||
| 95ae01e6dd | |||
| 1bd2db0719 | |||
| 6b831bd981 | |||
| 0014fd5f14 |
+128
-89
@@ -1,129 +1,168 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
type: vm
|
||||||
name: linux-amd64
|
name: linux-amd64
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
steps:
|
pool:
|
||||||
- name: test
|
use: ubuntu
|
||||||
image: golang:1.10
|
|
||||||
commands:
|
|
||||||
- cd posix
|
|
||||||
- tar -xf fixtures.tar -C /
|
|
||||||
- go test -v
|
|
||||||
|
|
||||||
- name: push
|
steps:
|
||||||
image: plugins/docker
|
- name: build
|
||||||
settings:
|
image: golang:1.10
|
||||||
auto_tag: true
|
commands:
|
||||||
auto_tag_suffix: linux-amd64
|
- cd posix
|
||||||
dockerfile: docker/Dockerfile.linux.amd64
|
- tar -xf fixtures.tar -C /
|
||||||
password:
|
- go test -v
|
||||||
$secret: password
|
|
||||||
repo: drone/git
|
- name: publish
|
||||||
username: drone
|
image: plugins/docker:18
|
||||||
when:
|
settings:
|
||||||
event:
|
dockerfile: docker/Dockerfile.linux.amd64
|
||||||
- push
|
repo: drone/git
|
||||||
- tag
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: linux-amd64
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
type: vm
|
||||||
name: linux-arm64
|
name: linux-arm64
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: arm64
|
arch: arm64
|
||||||
|
|
||||||
steps:
|
pool:
|
||||||
- name: test
|
use: ubuntu_arm64
|
||||||
image: golang:1.10
|
|
||||||
commands:
|
|
||||||
- cd posix
|
|
||||||
- tar -xf fixtures.tar -C /
|
|
||||||
- go test -v
|
|
||||||
|
|
||||||
- name: push
|
steps:
|
||||||
image: plugins/docker:linux-arm64
|
- name: build
|
||||||
settings:
|
image: golang:1.10
|
||||||
auto_tag: true
|
commands:
|
||||||
auto_tag_suffix: linux-arm64
|
- cd posix
|
||||||
dockerfile: docker/Dockerfile.linux.arm64
|
- tar -xf fixtures.tar -C /
|
||||||
password:
|
- go test -v
|
||||||
$secret: password
|
|
||||||
repo: drone/git
|
- name: publish
|
||||||
username: drone
|
image: plugins/docker:18
|
||||||
when:
|
settings:
|
||||||
event:
|
dockerfile: docker/Dockerfile.linux.arm64
|
||||||
- push
|
repo: drone/git
|
||||||
- tag
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: linux-arm64
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: linux-arm
|
type: vm
|
||||||
|
name: windows-1809
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: windows
|
||||||
arch: arm
|
arch: amd64
|
||||||
|
|
||||||
|
pool:
|
||||||
|
use: windows
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: test
|
- name: docker
|
||||||
image: golang:1.10
|
image: plugins/docker
|
||||||
commands:
|
settings:
|
||||||
- cd posix
|
dockerfile: docker/Dockerfile.windows.1809
|
||||||
- tar -xf fixtures.tar -C /
|
repo: drone/git
|
||||||
- go test -v
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: windows-1809-amd64
|
||||||
|
daemon_off: true
|
||||||
|
purge: false
|
||||||
|
|
||||||
- name: push
|
trigger:
|
||||||
image: plugins/docker:linux-arm
|
event:
|
||||||
settings:
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: linux-arm
|
|
||||||
dockerfile: docker/Dockerfile.linux.arm
|
|
||||||
password:
|
|
||||||
$secret: password
|
|
||||||
repo: drone/git
|
|
||||||
username: drone
|
|
||||||
when:
|
|
||||||
event:
|
|
||||||
- push
|
- push
|
||||||
- tag
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
name: after
|
type: vm
|
||||||
|
name: windows-ltsc2022
|
||||||
|
|
||||||
|
platform:
|
||||||
|
os: windows
|
||||||
|
arch: amd64
|
||||||
|
|
||||||
|
pool:
|
||||||
|
use: windows-2022
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
dockerfile: docker/Dockerfile.windows.ltsc2022
|
||||||
|
repo: drone/git
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
auto_tag: true
|
||||||
|
auto_tag_suffix: windows-ltsc2022-amd64
|
||||||
|
daemon_off: true
|
||||||
|
purge: false
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: vm
|
||||||
|
name: manifest
|
||||||
|
|
||||||
platform:
|
platform:
|
||||||
os: linux
|
os: linux
|
||||||
arch: amd64
|
arch: amd64
|
||||||
|
|
||||||
|
pool:
|
||||||
|
use: ubuntu
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: manifest
|
- name: manifest
|
||||||
image: plugins/manifest:1
|
image: plugins/manifest
|
||||||
settings:
|
settings:
|
||||||
ignore_missing: true
|
auto_tag: "true"
|
||||||
password:
|
ignore_missing: "true"
|
||||||
$secret: password
|
spec: docker/manifest.tmpl
|
||||||
spec: docker/manifest.tmpl
|
username:
|
||||||
username: drone
|
from_secret: docker_username
|
||||||
when:
|
password:
|
||||||
branch:
|
from_secret: docker_password
|
||||||
- master
|
|
||||||
event:
|
trigger:
|
||||||
|
event:
|
||||||
- push
|
- push
|
||||||
|
- tag
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- linux-arm
|
- linux-amd64
|
||||||
- linux-arm64
|
- linux-arm64
|
||||||
- linux-amd64
|
- windows-1809
|
||||||
|
- windows-ltsc2022
|
||||||
---
|
|
||||||
kind: secret
|
|
||||||
type: external
|
|
||||||
data:
|
|
||||||
password: "drone/docker#password"
|
|
||||||
username: "drone/docker#username"
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
.drone.jsonnet
|
|
||||||
.drone.jsonnet.yml
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
inputSet:
|
||||||
|
name: event-PR
|
||||||
|
identifier: eventPR
|
||||||
|
orgIdentifier: default
|
||||||
|
projectIdentifier: Drone_Plugins
|
||||||
|
pipeline:
|
||||||
|
identifier: dronegitharness
|
||||||
|
properties:
|
||||||
|
ci:
|
||||||
|
codebase:
|
||||||
|
build:
|
||||||
|
type: PR
|
||||||
|
spec:
|
||||||
|
number: <+trigger.prNumber>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
inputSet:
|
||||||
|
name: event-Push
|
||||||
|
identifier: eventPush
|
||||||
|
orgIdentifier: default
|
||||||
|
projectIdentifier: Drone_Plugins
|
||||||
|
pipeline:
|
||||||
|
identifier: dronegitharness
|
||||||
|
properties:
|
||||||
|
ci:
|
||||||
|
codebase:
|
||||||
|
build:
|
||||||
|
type: branch
|
||||||
|
spec:
|
||||||
|
branch: <+trigger.branch>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
inputSet:
|
||||||
|
name: eventTag
|
||||||
|
identifier: eventTag
|
||||||
|
orgIdentifier: default
|
||||||
|
projectIdentifier: Drone_Plugins
|
||||||
|
pipeline:
|
||||||
|
identifier: dronegitharness
|
||||||
|
properties:
|
||||||
|
ci:
|
||||||
|
codebase:
|
||||||
|
build:
|
||||||
|
type: tag
|
||||||
|
spec:
|
||||||
|
tag: <+trigger.tag>
|
||||||
@@ -0,0 +1,290 @@
|
|||||||
|
pipeline:
|
||||||
|
name: drone-git-harness
|
||||||
|
identifier: dronegitharness
|
||||||
|
projectIdentifier: Drone_Plugins
|
||||||
|
orgIdentifier: default
|
||||||
|
tags: {}
|
||||||
|
properties:
|
||||||
|
ci:
|
||||||
|
codebase:
|
||||||
|
connectorRef: GitHub_Drone_Org
|
||||||
|
repoName: drone-git
|
||||||
|
build: <+input>
|
||||||
|
sparseCheckout: []
|
||||||
|
stages:
|
||||||
|
- stage:
|
||||||
|
name: Testing
|
||||||
|
identifier: Testing
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: true
|
||||||
|
platform:
|
||||||
|
os: Linux
|
||||||
|
arch: Amd64
|
||||||
|
runtime:
|
||||||
|
type: Cloud
|
||||||
|
spec: {}
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Run
|
||||||
|
name: Test
|
||||||
|
identifier: Test
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: golang:1.10
|
||||||
|
shell: Sh
|
||||||
|
command: |-
|
||||||
|
cd posix
|
||||||
|
tar -xf fixtures.tar -C /
|
||||||
|
go test -v
|
||||||
|
- parallel:
|
||||||
|
- stage:
|
||||||
|
name: linux-amd64
|
||||||
|
identifier: linuxamd64
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: false
|
||||||
|
paths: []
|
||||||
|
platform:
|
||||||
|
os: Linux
|
||||||
|
arch: Amd64
|
||||||
|
runtime:
|
||||||
|
type: Cloud
|
||||||
|
spec: {}
|
||||||
|
buildIntelligence:
|
||||||
|
enabled: false
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Run
|
||||||
|
name: Build Binary
|
||||||
|
identifier: Build
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: golang:1.10
|
||||||
|
shell: Sh
|
||||||
|
command: |-
|
||||||
|
cd posix
|
||||||
|
tar -xf fixtures.tar -C /
|
||||||
|
go test -v
|
||||||
|
- step:
|
||||||
|
type: Plugin
|
||||||
|
name: BuildAndPushDockerPlugin
|
||||||
|
identifier: BuildAndPushDockerPlugin
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: plugins/docker:18
|
||||||
|
settings:
|
||||||
|
username: drone
|
||||||
|
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
|
||||||
|
repo: plugins/git
|
||||||
|
dockerfile: docker/Dockerfile.linux.amd64
|
||||||
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: linux-amd64
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: <+codebase.build.type> == "tag"
|
||||||
|
- step:
|
||||||
|
type: BuildAndPushDockerRegistry
|
||||||
|
name: BuildAndPushDockerRegistry_1
|
||||||
|
identifier: BuildAndPushDockerRegistry_1
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
repo: plugins/git
|
||||||
|
tags:
|
||||||
|
- linux-amd64
|
||||||
|
caching: false
|
||||||
|
dockerfile: docker/Dockerfile.linux.amd64
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: |
|
||||||
|
<+codebase.build.type> == "branch"
|
||||||
|
- stage:
|
||||||
|
name: linux-arm64
|
||||||
|
identifier: linuxarm64
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: false
|
||||||
|
paths: []
|
||||||
|
platform:
|
||||||
|
os: Linux
|
||||||
|
arch: Arm64
|
||||||
|
runtime:
|
||||||
|
type: Cloud
|
||||||
|
spec: {}
|
||||||
|
buildIntelligence:
|
||||||
|
enabled: false
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Run
|
||||||
|
name: Build Binary
|
||||||
|
identifier: Build
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: golang:1.10
|
||||||
|
shell: Sh
|
||||||
|
command: |-
|
||||||
|
cd posix
|
||||||
|
tar -xf fixtures.tar -C /
|
||||||
|
go test -v
|
||||||
|
- step:
|
||||||
|
type: Plugin
|
||||||
|
name: BuildAndPushDockerPlugin
|
||||||
|
identifier: BuildAndPushDockerPlugin
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: plugins/docker:18
|
||||||
|
settings:
|
||||||
|
username: drone
|
||||||
|
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
|
||||||
|
repo: plugins/git
|
||||||
|
dockerfile: docker/Dockerfile.linux.arm64
|
||||||
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: linux-arm64
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: <+codebase.build.type> == "tag"
|
||||||
|
- step:
|
||||||
|
type: BuildAndPushDockerRegistry
|
||||||
|
name: BuildAndPushDockerRegistry_1
|
||||||
|
identifier: BuildAndPushDockerRegistry_1
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
repo: plugins/git
|
||||||
|
tags:
|
||||||
|
- linux-arm64
|
||||||
|
caching: false
|
||||||
|
dockerfile: docker/Dockerfile.linux.arm64
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: |
|
||||||
|
<+codebase.build.type> == "branch"
|
||||||
|
- stage:
|
||||||
|
name: windows-1809
|
||||||
|
identifier: windows1809
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: false
|
||||||
|
paths: []
|
||||||
|
buildIntelligence:
|
||||||
|
enabled: false
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Plugin
|
||||||
|
name: BuildAndPushDockerPlugin
|
||||||
|
identifier: BuildAndPushDockerPlugin
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username: drone
|
||||||
|
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
|
||||||
|
repo: plugins/git
|
||||||
|
dockerfile: docker/Dockerfile.windows.1809
|
||||||
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: windows-1809-amd64
|
||||||
|
daemon_off: "true"
|
||||||
|
purge: "false"
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: <+codebase.build.type> == "branch"
|
||||||
|
infrastructure:
|
||||||
|
type: VM
|
||||||
|
spec:
|
||||||
|
type: Pool
|
||||||
|
spec:
|
||||||
|
poolName: windows-2019
|
||||||
|
os: Windows
|
||||||
|
delegateSelectors:
|
||||||
|
- windows-vm
|
||||||
|
- stage:
|
||||||
|
name: windows-ltsc2022
|
||||||
|
identifier: windowsltsc2022
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: false
|
||||||
|
paths: []
|
||||||
|
platform:
|
||||||
|
os: Windows
|
||||||
|
arch: Amd64
|
||||||
|
runtime:
|
||||||
|
type: Cloud
|
||||||
|
spec: {}
|
||||||
|
buildIntelligence:
|
||||||
|
enabled: false
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Plugin
|
||||||
|
name: BuildAndPushDockerPlugin
|
||||||
|
identifier: BuildAndPushDockerPlugin
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username: drone
|
||||||
|
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
|
||||||
|
repo: plugins/git
|
||||||
|
dockerfile: docker/Dockerfile.windows.ltsc2022
|
||||||
|
auto_tag: "true"
|
||||||
|
auto_tag_suffix: windows-ltsc2022-amd64
|
||||||
|
daemon_off: "true"
|
||||||
|
purge: "false"
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: <+codebase.build.type> == "branch"
|
||||||
|
- stage:
|
||||||
|
name: manifest
|
||||||
|
identifier: manifest
|
||||||
|
description: ""
|
||||||
|
type: CI
|
||||||
|
spec:
|
||||||
|
cloneCodebase: true
|
||||||
|
caching:
|
||||||
|
enabled: false
|
||||||
|
paths: []
|
||||||
|
platform:
|
||||||
|
os: Linux
|
||||||
|
arch: Amd64
|
||||||
|
runtime:
|
||||||
|
type: Cloud
|
||||||
|
spec: {}
|
||||||
|
execution:
|
||||||
|
steps:
|
||||||
|
- step:
|
||||||
|
type: Plugin
|
||||||
|
name: Manifest
|
||||||
|
identifier: Manifest
|
||||||
|
spec:
|
||||||
|
connectorRef: Plugins_Docker_Hub_Connector
|
||||||
|
image: plugins/manifest
|
||||||
|
settings:
|
||||||
|
username: drone
|
||||||
|
password: <+secrets.getValue("Plugins_Docker_Hub_Pat")>
|
||||||
|
ignore_missing: "true"
|
||||||
|
spec: docker/manifest.tmpl
|
||||||
|
auto_tag: "true"
|
||||||
|
when:
|
||||||
|
stageStatus: Success
|
||||||
|
condition: <+codebase.build.type> == "branch" || <+codebase.build.type> == "tag"
|
||||||
|
buildIntelligence:
|
||||||
|
enabled: false
|
||||||
|
allowStageExecutions: true
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
### Added
|
||||||
|
|
||||||
|
## [1.1.0]
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Ability to clone tags for promotion events from [@josmo](https://github.com/josme)
|
||||||
|
- Support for git lfs in base images from [@carlwgeorge](https://github.com/carlwgeorge)
|
||||||
|
- Support for windows 1803 from [@donny-dont](https://github.com/donny-dont)
|
||||||
|
- Support for windows 1809 from [@donny-dont](https://github.com/donny-dont)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed error merging when missing email from [@bradrydzewski](https://github.com/bradrydzewski)
|
||||||
|
- Fixed empty ref on windows from [@drpebcak](https://github.com/drpebcak)
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# drone-git
|
||||||
|
|
||||||
|
Drone plugin to clone `git` repositories.
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
Build the Docker image with the following commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker build --rm -f docker/Dockerfile.linux.amd64 -t drone/git .
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Clone a commit:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run --rm \
|
||||||
|
-e DRONE_WORKSPACE=/drone \
|
||||||
|
-e DRONE_REMOTE_URL=https://github.com/drone/envsubst.git \
|
||||||
|
-e DRONE_BUILD_EVENT=push \
|
||||||
|
-e DRONE_COMMIT_SHA=15e3f9b7e16332eee3bbdff9ef31f95d23c5da2c \
|
||||||
|
-e DRONE_COMMIT_BRANCH=master \
|
||||||
|
drone/git
|
||||||
|
```
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
FROM alpine:3.6
|
FROM alpine:3.12
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
ADD posix/* /usr/local/bin/
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
|
||||||
|
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||||
|
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||||
|
# USER drone:drone
|
||||||
|
# RUN chmod -R 777 /home/drone
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM arm32v6/alpine:3.6
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM arm32v6/alpine:3.6
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
FROM arm64v8/alpine:3.6
|
FROM arm64v8/alpine:3.12
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
RUN apk add --no-cache ca-certificates git git-lfs openssh curl perl aws-cli sudo
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
ADD posix/* /usr/local/bin/
|
||||||
|
|
||||||
|
# RUN adduser -g Drone -s /bin/sh -D -u 1000 drone
|
||||||
|
# RUN echo 'drone ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/drone
|
||||||
|
# USER drone:drone
|
||||||
|
# RUN chmod -R 777 /home/drone
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
ENTRYPOINT ["/usr/local/bin/clone"]
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM arm32v6/alpine:3.6
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM arm64v8/alpine:3.6
|
|
||||||
RUN apk add --no-cache ca-certificates git openssh curl perl
|
|
||||||
|
|
||||||
ADD posix/* /usr/local/bin/
|
|
||||||
ENTRYPOINT ["/usr/local/bin/clone"]
|
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
FROM microsoft/windowsservercore:1709 AS git
|
# escape=`
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/windows/servercore:1809 AS git
|
||||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
|
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \
|
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||||
Expand-Archive git.zip -DestinationPath C:\git
|
Expand-Archive git.zip -DestinationPath C:\git;
|
||||||
|
|
||||||
FROM microsoft/powershell:nanoserver-1709
|
FROM mcr.microsoft.com/powershell:nanoserver-1809
|
||||||
COPY --from=git /git /git
|
COPY --from=git /git /git
|
||||||
|
|
||||||
ADD windows/* /bin/
|
ADD windows/* /bin/
|
||||||
@@ -14,7 +16,5 @@ ADD windows/* /bin/
|
|||||||
USER ContainerAdministrator
|
USER ContainerAdministrator
|
||||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||||
|
|
||||||
ENV HOME C:\\Users\\ContainerAdministrator
|
|
||||||
|
|
||||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
FROM microsoft/windowsservercore:1803 AS git
|
# escape=`
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/windows/servercore:ltsc2022 AS git
|
||||||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; \
|
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
|
||||||
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.19.0-rc2.windows.1/MinGit-2.19.0.rc2.windows.1-64-bit.zip -OutFile git.zip; \
|
Invoke-WebRequest -UseBasicParsing https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/MinGit-2.21.0-64-bit.zip -OutFile git.zip; `
|
||||||
Expand-Archive git.zip -DestinationPath C:\git
|
Expand-Archive git.zip -DestinationPath C:\git;
|
||||||
|
|
||||||
FROM microsoft/powershell:nanoserver-1803
|
FROM mcr.microsoft.com/powershell:nanoserver-ltsc2022
|
||||||
COPY --from=git /git /git
|
COPY --from=git /git /git
|
||||||
|
|
||||||
ADD windows/* /bin/
|
ADD windows/* /bin/
|
||||||
@@ -14,7 +16,5 @@ ADD windows/* /bin/
|
|||||||
USER ContainerAdministrator
|
USER ContainerAdministrator
|
||||||
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
|
||||||
|
|
||||||
ENV HOME C:\\Users\\ContainerAdministrator
|
|
||||||
|
|
||||||
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
CMD [ "pwsh", "C:\\bin\\clone.ps1" ]
|
||||||
+17
-17
@@ -1,31 +1,31 @@
|
|||||||
image: drone/git:latest
|
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||||
|
{{#if build.tags}}
|
||||||
|
tags:
|
||||||
|
{{#each build.tags}}
|
||||||
|
- {{this}}
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
manifests:
|
manifests:
|
||||||
-
|
-
|
||||||
image: drone/git:linux-amd64
|
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||||
platform:
|
platform:
|
||||||
architecture: amd64
|
architecture: amd64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
-
|
||||||
image: drone/git:linux-arm64
|
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||||
platform:
|
platform:
|
||||||
variant: v8
|
variant: v8
|
||||||
architecture: arm64
|
architecture: arm64
|
||||||
os: linux
|
os: linux
|
||||||
-
|
-
|
||||||
image: drone/git:linux-arm
|
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-1809-amd64
|
||||||
platform:
|
platform:
|
||||||
variant: v7
|
architecture: amd64
|
||||||
architecture: arm
|
os: windows
|
||||||
os: linux
|
version: 1809
|
||||||
-
|
-
|
||||||
image: drone/git:linux-arm
|
image: drone/git:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}windows-ltsc2022-amd64
|
||||||
platform:
|
platform:
|
||||||
variant: v6
|
architecture: amd64
|
||||||
architecture: arm
|
os: windows
|
||||||
os: linux
|
version: ltsc2022
|
||||||
-
|
|
||||||
image: drone/git:windows-1803
|
|
||||||
platform:
|
|
||||||
architecture: arm
|
|
||||||
os: linux
|
|
||||||
os.version: 10.0.17134.165
|
|
||||||
+79
-18
@@ -1,14 +1,31 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
if [[ -n "${DRONE_WORKSPACE}" ]]; then
|
||||||
|
# ensure the unprivileged drone user can write
|
||||||
|
# to the workspace. This is required because
|
||||||
|
# the workspace is a docker volume and is owned
|
||||||
|
# by root.
|
||||||
|
# sudo mkdir -p ${DRONE_WORKSPACE}
|
||||||
|
# sudo chown drone:drone ${DRONE_WORKSPACE}
|
||||||
|
|
||||||
|
# ensure the workspace is the current working
|
||||||
|
# directory. This should already be the case,
|
||||||
|
# but we cd just to be safe.
|
||||||
cd ${DRONE_WORKSPACE}
|
cd ${DRONE_WORKSPACE}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# force the home directory path.
|
||||||
|
|
||||||
|
# if [ "$HOME" != "/home/drone" ]; then
|
||||||
|
# echo "[DEBUG] setting default home directory"
|
||||||
|
# export HOME=/home/drone
|
||||||
|
# fi
|
||||||
|
|
||||||
# if the netrc enviornment variables exist, write
|
# if the netrc enviornment variables exist, write
|
||||||
# the netrc file.
|
# the netrc file.
|
||||||
|
|
||||||
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||||
cat <<EOF > /root/.netrc
|
cat <<EOF > ${HOME}/.netrc
|
||||||
machine ${DRONE_NETRC_MACHINE}
|
machine ${DRONE_NETRC_MACHINE}
|
||||||
login ${DRONE_NETRC_USERNAME}
|
login ${DRONE_NETRC_USERNAME}
|
||||||
password ${DRONE_NETRC_PASSWORD}
|
password ${DRONE_NETRC_PASSWORD}
|
||||||
@@ -19,38 +36,82 @@ fi
|
|||||||
# the ssh key and add the netrc machine to the
|
# the ssh key and add the netrc machine to the
|
||||||
# known hosts file.
|
# known hosts file.
|
||||||
|
|
||||||
if [[ ! -z "${SSH_KEY}" ]]; then
|
if [[ ! -z "${DRONE_SSH_KEY}" ]]; then
|
||||||
mkdir /root/.ssh
|
mkdir ${HOME}/.ssh
|
||||||
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
|
echo -n "$DRONE_SSH_KEY" > ${HOME}/.ssh/id_rsa
|
||||||
chmod 600 /root/.ssh/id_rsa
|
chmod 600 ${HOME}/.ssh/id_rsa
|
||||||
|
|
||||||
touch /root/.ssh/known_hosts
|
touch ${HOME}/.ssh/known_hosts
|
||||||
chmod 600 /root/.ssh/known_hosts
|
chmod 600 ${HOME}/.ssh/known_hosts
|
||||||
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# AWS codecommit support using AWS access key & secret key
|
||||||
|
# Refer: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-https-unixes.html
|
||||||
|
|
||||||
|
if [[ ! -z "$DRONE_AWS_ACCESS_KEY" ]]; then
|
||||||
|
aws configure set aws_access_key_id $DRONE_AWS_ACCESS_KEY
|
||||||
|
aws configure set aws_secret_access_key $DRONE_AWS_SECRET_KEY
|
||||||
|
aws configure set default.region $DRONE_AWS_REGION
|
||||||
|
|
||||||
|
git config --global credential.helper '!aws codecommit credential-helper $@'
|
||||||
|
git config --global credential.UseHttpPath true
|
||||||
|
fi
|
||||||
|
|
||||||
# configure git global behavior and parameters via the
|
# configure git global behavior and parameters via the
|
||||||
# following environment variables:
|
# following environment variables:
|
||||||
|
|
||||||
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME=drone}
|
|
||||||
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost}
|
|
||||||
export GIT_COMMITTER_NAME=${GIT_AUTHOR_NAME}
|
|
||||||
export GIT_COMMITTER_EMAIL=${GIT_AUTHOR_EMAIL}
|
|
||||||
# GIT_SSL_NO_VERIFY=
|
|
||||||
|
|
||||||
|
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||||
|
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||||
|
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||||
|
fi
|
||||||
|
|
||||||
|
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||||
|
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||||
|
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||||
|
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||||
|
|
||||||
# invoke the sub-script based on the drone event type.
|
# invoke the sub-script based on the drone event type.
|
||||||
# TODO we should ultimately look at the ref, since
|
# TODO we should ultimately look at the ref, since
|
||||||
# we need something compatible with deployment events.
|
# we need something compatible with deployment events.
|
||||||
|
|
||||||
case $DRONE_BUILD_EVENT in
|
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||||
|
case $DRONE_COMMIT_REF in
|
||||||
|
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||||
|
refs/pull/* ) CLONE_TYPE=pull_request ;;
|
||||||
|
refs/pull-request/* ) CLONE_TYPE=pull_request ;;
|
||||||
|
refs/merge-requests/* ) CLONE_TYPE=pull_request ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
git_clone_retry(){
|
||||||
|
retries="${PLUGIN_RETRIES:-0}"
|
||||||
|
if [ -n "${retries##*[0-9]*}" ] || [ "${retries}" -lt 0 ]; then
|
||||||
|
echo "PLUGIN_RETRIES defined but is not a number: ${retries}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Cloning with ${retries} retries"
|
||||||
|
n=0
|
||||||
|
until [ "$n" -gt "${retries}" ]; do
|
||||||
|
$1 && return
|
||||||
|
n=$((n+1))
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
case $CLONE_TYPE in
|
||||||
pull_request)
|
pull_request)
|
||||||
clone-pull-request
|
git_clone_retry clone-pull-request
|
||||||
;;
|
;;
|
||||||
tag)
|
tag)
|
||||||
clone-tag
|
git_clone_retry clone-tag
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
clone-commit
|
git_clone_retry clone-commit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -10,6 +10,30 @@ if [ ! -d .git ]; then
|
|||||||
git remote add origin ${DRONE_REMOTE_URL}
|
git remote add origin ${DRONE_REMOTE_URL}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# the branch may be empty for certain event types,
|
||||||
|
# such as github deployment events. If the branch
|
||||||
|
# is empty we checkout the sha directly. Note that
|
||||||
|
# we intentially omit depth flags to avoid failed
|
||||||
|
# clones due to lack of history.
|
||||||
|
if [[ -z "${DRONE_COMMIT_BRANCH}" ]]; then
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
git fetch origin
|
||||||
|
git checkout -qf ${DRONE_COMMIT_SHA}
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# the commit sha may be empty for builds that are
|
||||||
|
# manually triggered in Harness CI Enterprise. If
|
||||||
|
# the commit is empty we clone the branch.
|
||||||
|
if [[ -z "${DRONE_COMMIT_SHA}" ]]; then
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||||
|
git checkout -b ${DRONE_COMMIT_BRANCH} origin/${DRONE_COMMIT_BRANCH}
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
|||||||
git checkout ${DRONE_COMMIT_BRANCH}
|
git checkout ${DRONE_COMMIT_BRANCH}
|
||||||
|
|
||||||
git fetch origin ${DRONE_COMMIT_REF}:
|
git fetch origin ${DRONE_COMMIT_REF}:
|
||||||
git rebase ${DRONE_COMMIT_SHA}
|
git merge ${DRONE_COMMIT_SHA}
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
package posix
|
package posix
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/includetext.go --input=clone --input=clone-commit --input=clone-pull-request --input=clone-tag --package=posix --output=posix_gen.go
|
||||||
|
|||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package posix
|
||||||
|
|
||||||
|
// DO NOT EDIT. This file is automatically generated.
|
||||||
|
|
||||||
|
// Contents of clone
|
||||||
|
const Clone = `#!/bin/sh
|
||||||
|
|
||||||
|
if [[ ! -z "${DRONE_WORKSPACE}" ]]; then
|
||||||
|
cd ${DRONE_WORKSPACE}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if the netrc enviornment variables exist, write
|
||||||
|
# the netrc file.
|
||||||
|
|
||||||
|
if [[ ! -z "${DRONE_NETRC_MACHINE}" ]]; then
|
||||||
|
cat <<EOF > /root/.netrc
|
||||||
|
machine ${DRONE_NETRC_MACHINE}
|
||||||
|
login ${DRONE_NETRC_USERNAME}
|
||||||
|
password ${DRONE_NETRC_PASSWORD}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# if the ssh_key environment variable exists, write
|
||||||
|
# the ssh key and add the netrc machine to the
|
||||||
|
# known hosts file.
|
||||||
|
|
||||||
|
if [[ ! -z "${SSH_KEY}" ]]; then
|
||||||
|
mkdir /root/.ssh
|
||||||
|
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
|
||||||
|
chmod 600 /root/.ssh/id_rsa
|
||||||
|
|
||||||
|
touch /root/.ssh/known_hosts
|
||||||
|
chmod 600 /root/.ssh/known_hosts
|
||||||
|
ssh-keyscan -H ${DRONE_NETRC_MACHINE} > /etc/ssh/ssh_known_hosts 2> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# configure git global behavior and parameters via the
|
||||||
|
# following environment variables:
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -z "${DRONE_COMMIT_AUTHOR_NAME}" ]]; then
|
||||||
|
export DRONE_COMMIT_AUTHOR_NAME=drone
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "${DRONE_COMMIT_AUTHOR_EMAIL}" ]]; then
|
||||||
|
export DRONE_COMMIT_AUTHOR_EMAIL=drone@localhost
|
||||||
|
fi
|
||||||
|
|
||||||
|
export GIT_AUTHOR_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||||
|
export GIT_AUTHOR_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||||
|
export GIT_COMMITTER_NAME=${DRONE_COMMIT_AUTHOR_NAME}
|
||||||
|
export GIT_COMMITTER_EMAIL=${DRONE_COMMIT_AUTHOR_EMAIL}
|
||||||
|
|
||||||
|
# invoke the sub-script based on the drone event type.
|
||||||
|
# TODO we should ultimately look at the ref, since
|
||||||
|
# we need something compatible with deployment events.
|
||||||
|
|
||||||
|
CLONE_TYPE=$DRONE_BUILD_EVENT
|
||||||
|
case $DRONE_COMMIT_REF in
|
||||||
|
refs/tags/* ) CLONE_TYPE=tag ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case $CLONE_TYPE in
|
||||||
|
pull_request)
|
||||||
|
clone-pull-request
|
||||||
|
;;
|
||||||
|
tag)
|
||||||
|
clone-tag
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
clone-commit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-commit
|
||||||
|
const CloneCommit = `#!/bin/sh
|
||||||
|
|
||||||
|
FLAGS=""
|
||||||
|
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||||
|
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
git init
|
||||||
|
git remote add origin ${DRONE_REMOTE_URL}
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||||
|
git checkout ${DRONE_COMMIT_SHA} -b ${DRONE_COMMIT_BRANCH}
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-pull-request
|
||||||
|
const ClonePullRequest = `#!/bin/sh
|
||||||
|
|
||||||
|
FLAGS=""
|
||||||
|
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||||
|
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
git init
|
||||||
|
git remote add origin ${DRONE_REMOTE_URL}
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
git fetch ${FLAGS} origin +refs/heads/${DRONE_COMMIT_BRANCH}:
|
||||||
|
git checkout ${DRONE_COMMIT_BRANCH}
|
||||||
|
|
||||||
|
git fetch origin ${DRONE_COMMIT_REF}:
|
||||||
|
git merge ${DRONE_COMMIT_SHA}
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-tag
|
||||||
|
const CloneTag = `#!/bin/sh
|
||||||
|
|
||||||
|
FLAGS=""
|
||||||
|
if [[ ! -z "${PLUGIN_DEPTH}" ]]; then
|
||||||
|
FLAGS="--depth=${PLUGIN_DEPTH}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d .git ]; then
|
||||||
|
git init
|
||||||
|
git remote add origin ${DRONE_REMOTE_URL}
|
||||||
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -x
|
||||||
|
|
||||||
|
git fetch ${FLAGS} origin +refs/tags/${DRONE_TAG}:
|
||||||
|
git checkout -qf FETCH_HEAD
|
||||||
|
`
|
||||||
|
|
||||||
+2
-2
@@ -166,7 +166,7 @@ func TestPullRequest(t *testing.T) {
|
|||||||
cmd.Dir = local
|
cmd.Dir = local
|
||||||
cmd.Env = []string{
|
cmd.Env = []string{
|
||||||
fmt.Sprintf("DRONE_COMMIT_REF=%s", "refs/pull/14596/head"),
|
fmt.Sprintf("DRONE_COMMIT_REF=%s", "refs/pull/14596/head"),
|
||||||
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", "master"),
|
fmt.Sprintf("DRONE_COMMIT_BRANCH=%s", "main"),
|
||||||
fmt.Sprintf("DRONE_COMMIT_SHA=%s", "26923a8f37933ccc23943de0d4ebd53908268582"),
|
fmt.Sprintf("DRONE_COMMIT_SHA=%s", "26923a8f37933ccc23943de0d4ebd53908268582"),
|
||||||
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
|
fmt.Sprintf("DRONE_WORKSPACE=%s", local),
|
||||||
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
|
fmt.Sprintf("DRONE_REMOTE_URL=%s", remote),
|
||||||
@@ -195,7 +195,7 @@ func TestPullRequest(t *testing.T) {
|
|||||||
t.Errorf("Want commit %s, got %s", want, got)
|
t.Errorf("Want commit %s, got %s", want, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
if want, got := "master", branch; got != want {
|
if want, got := "main", branch; got != want {
|
||||||
t.Errorf("Want branch %s, got %s", want, got)
|
t.Errorf("Want branch %s, got %s", want, got)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
// +build ignore
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
input stringSlice
|
||||||
|
output string
|
||||||
|
name string
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Var(&input, "input", "input files")
|
||||||
|
flag.StringVar(&output, "output", "", "output file")
|
||||||
|
flag.StringVar(&name, "package", "", "package name")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
var files []File
|
||||||
|
for _, file := range input {
|
||||||
|
out, err := ioutil.ReadFile(file)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
files = append(files, File{
|
||||||
|
Name: file,
|
||||||
|
Slug: slugify(file),
|
||||||
|
Data: string(out),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
data := map[string]interface{}{
|
||||||
|
"Files": files,
|
||||||
|
"Package": name,
|
||||||
|
}
|
||||||
|
buf := new(bytes.Buffer)
|
||||||
|
err := tmpl.Execute(buf, data)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalln(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ioutil.WriteFile(output, buf.Bytes(), 0644)
|
||||||
|
}
|
||||||
|
|
||||||
|
func slugify(s string) string {
|
||||||
|
ext := filepath.Ext(s)
|
||||||
|
s = strings.TrimSuffix(s, ext)
|
||||||
|
s = strings.Title(s)
|
||||||
|
s = strings.ReplaceAll(s, "-", "")
|
||||||
|
s = strings.ReplaceAll(s, "_", "")
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
type stringSlice []string
|
||||||
|
|
||||||
|
func (s *stringSlice) String() string {
|
||||||
|
return strings.Join(*s, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *stringSlice) Set(value string) error {
|
||||||
|
*s = append(*s, value)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type File struct {
|
||||||
|
Name string
|
||||||
|
Data string
|
||||||
|
Slug string
|
||||||
|
}
|
||||||
|
|
||||||
|
var tmpl = template.Must(template.New("_").Parse(`package {{ .Package }}
|
||||||
|
|
||||||
|
// DO NOT EDIT. This file is automatically generated.
|
||||||
|
|
||||||
|
{{ range .Files -}}
|
||||||
|
// Contents of {{ .Name }}
|
||||||
|
const {{ .Slug }} = ` + "`{{ .Data }}`" + `
|
||||||
|
|
||||||
|
{{ end -}}`))
|
||||||
@@ -5,9 +5,13 @@ if ($Env:PLUGIN_DEPTH) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(Test-Path .git)) {
|
if (!(Test-Path .git)) {
|
||||||
|
Write-Host 'git init';
|
||||||
git init
|
git init
|
||||||
|
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||||
git remote add origin $Env:DRONE_REMOTE_URL
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||||
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||||
|
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||||
|
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Set-Variable -Name "FLAGS" -Value ""
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
if ($Env:PLUGIN_DEPTH) {
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(Test-Path .git)) {
|
if (!(Test-Path .git)) {
|
||||||
@@ -12,5 +12,5 @@ if (!(Test-Path .git)) {
|
|||||||
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||||
git checkout $Env:DRONE_COMMIT_BRANCH
|
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||||
|
|
||||||
git fetch origin $Env:DRONE_COMMIT_REF:
|
git fetch origin "${Env:DRONE_COMMIT_REF}:"
|
||||||
git rebase $Env:DRONE_COMMIT_SHA
|
git merge $Env:DRONE_COMMIT_SHA
|
||||||
|
|||||||
+13
-13
@@ -15,11 +15,11 @@ if ($Env:DRONE_WORKSPACE) {
|
|||||||
# the netrc file.
|
# the netrc file.
|
||||||
|
|
||||||
if ($Env:DRONE_NETRC_MACHINE) {
|
if ($Env:DRONE_NETRC_MACHINE) {
|
||||||
|
@"
|
||||||
$netrc=[string]::Format("{0}\_netrc",$Env:HOME);
|
machine $Env:DRONE_NETRC_MACHINE
|
||||||
"machine $Env:CI_NETRC_MACHINE" >> $netrc;
|
login $Env:DRONE_NETRC_USERNAME
|
||||||
"login $Env:CI_NETRC_USERNAME" >> $netrc;
|
password $Env:DRONE_NETRC_PASSWORD
|
||||||
"password $Env:CI_NETRC_PASSWORD" >> $netrc;
|
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure git global behavior and parameters via the
|
# configure git global behavior and parameters via the
|
||||||
@@ -29,16 +29,16 @@ if ($Env:PLUGIN_SKIP_VERIFY) {
|
|||||||
$Env:GIT_SSL_NO_VERIFY = "true"
|
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
|
||||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
|
||||||
} else {
|
|
||||||
$Env:GIT_AUTHOR_NAME = "drone"
|
$Env:GIT_AUTHOR_NAME = "drone"
|
||||||
|
} else {
|
||||||
|
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($Env:DRONE_COMMIT_AUTHOR_NAME) {
|
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
|
||||||
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
|
||||||
} else {
|
} else {
|
||||||
$Env:GIT_AUTHOR_NAME = 'drone@localhost'
|
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||||
@@ -50,7 +50,7 @@ $Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
|||||||
|
|
||||||
switch ($Env:DRONE_BUILD_EVENT) {
|
switch ($Env:DRONE_BUILD_EVENT) {
|
||||||
"pull_request" {
|
"pull_request" {
|
||||||
Invoke-Expression "${PSScriptRoot}\clone-pull-reqest.ps1"
|
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
"tag" {
|
"tag" {
|
||||||
@@ -61,4 +61,4 @@ switch ($Env:DRONE_BUILD_EVENT) {
|
|||||||
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package windows
|
||||||
|
|
||||||
|
//go:generate go run ../scripts/includetext.go --input=clone.ps1 --input=clone-commit.ps1 --input=clone-pull-request.ps1 --input=clone-tag.ps1 --package=windows --output=windows_gen.go
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package windows
|
||||||
|
|
||||||
|
// DO NOT EDIT. This file is automatically generated.
|
||||||
|
|
||||||
|
// Contents of clone.ps1
|
||||||
|
const Clone = `$ErrorActionPreference = 'Stop';
|
||||||
|
|
||||||
|
# HACK: no clue how to set the PATH inside the Dockerfile,
|
||||||
|
# so am setting it here instead. This is not idea.
|
||||||
|
$Env:PATH += ';C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin'
|
||||||
|
|
||||||
|
# if the workspace is set we should make sure
|
||||||
|
# it is the current working directory.
|
||||||
|
|
||||||
|
if ($Env:DRONE_WORKSPACE) {
|
||||||
|
cd $Env:DRONE_WORKSPACE
|
||||||
|
}
|
||||||
|
|
||||||
|
# if the netrc enviornment variables exist, write
|
||||||
|
# the netrc file.
|
||||||
|
|
||||||
|
if ($Env:DRONE_NETRC_MACHINE) {
|
||||||
|
@"
|
||||||
|
machine $Env:DRONE_NETRC_MACHINE
|
||||||
|
login $Env:DRONE_NETRC_USERNAME
|
||||||
|
password $Env:DRONE_NETRC_PASSWORD
|
||||||
|
"@ > (Join-Path $Env:USERPROFILE '_netrc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# configure git global behavior and parameters via the
|
||||||
|
# following environment variables:
|
||||||
|
|
||||||
|
if ($Env:PLUGIN_SKIP_VERIFY) {
|
||||||
|
$Env:GIT_SSL_NO_VERIFY = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Env:DRONE_COMMIT_AUTHOR_NAME -eq '' -or $Env:DRONE_COMMIT_AUTHOR_NAME -eq $null) {
|
||||||
|
$Env:GIT_AUTHOR_NAME = "drone"
|
||||||
|
} else {
|
||||||
|
$Env:GIT_AUTHOR_NAME = $Env:DRONE_COMMIT_AUTHOR_NAME
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Env:DRONE_COMMIT_AUTHOR_EMAIL -eq '' -or $Env:DRONE_COMMIT_AUTHOR_EMAIL -eq $null) {
|
||||||
|
$Env:GIT_AUTHOR_EMAIL = 'drone@localhost'
|
||||||
|
} else {
|
||||||
|
$Env:GIT_AUTHOR_EMAIL = $Env:DRONE_COMMIT_AUTHOR_EMAIL
|
||||||
|
}
|
||||||
|
|
||||||
|
$Env:GIT_COMMITTER_NAME = $Env:GIT_AUTHOR_NAME
|
||||||
|
$Env:GIT_COMMITTER_EMAIL = $Env:GIT_AUTHOR_EMAIL
|
||||||
|
|
||||||
|
# invoke the sub-script based on the drone event type.
|
||||||
|
# TODO we should ultimately look at the ref, since
|
||||||
|
# we need something compatible with deployment events.
|
||||||
|
|
||||||
|
switch ($Env:DRONE_BUILD_EVENT) {
|
||||||
|
"pull_request" {
|
||||||
|
Invoke-Expression "${PSScriptRoot}\clone-pull-request.ps1"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
"tag" {
|
||||||
|
Invoke-Expression "${PSScriptRoot}\clone-tag.ps1"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
Invoke-Expression "${PSScriptRoot}\clone-commit.ps1"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-commit.ps1
|
||||||
|
const CloneCommit = `
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
Write-Host 'git init';
|
||||||
|
git init
|
||||||
|
Write-Host "git remote add origin $Env:DRONE_REMOTE_URL"
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "git fetch $FLAGS origin +refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||||
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:";
|
||||||
|
Write-Host "git checkout $Env:DRONE_COMMIT_SHA -f $Env:DRONE_COMMIT_BRANCH";
|
||||||
|
git checkout $Env:DRONE_COMMIT_SHA -b $Env:DRONE_COMMIT_BRANCH;
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-pull-request.ps1
|
||||||
|
const ClonePullRequest = `
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
git init
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
git fetch $FLAGS origin "+refs/heads/${Env:DRONE_COMMIT_BRANCH}:"
|
||||||
|
git checkout $Env:DRONE_COMMIT_BRANCH
|
||||||
|
|
||||||
|
git fetch origin "${Env:DRONE_COMMIT_REF}:"
|
||||||
|
git merge $Env:DRONE_COMMIT_SHA
|
||||||
|
`
|
||||||
|
|
||||||
|
// Contents of clone-tag.ps1
|
||||||
|
const CloneTag = `
|
||||||
|
Set-Variable -Name "FLAGS" -Value ""
|
||||||
|
if ($Env:PLUGIN_DEPTH) {
|
||||||
|
Set-Variable -Name "FLAGS" -Value "--depth=$Env:PLUGIN_DEPTH"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path .git)) {
|
||||||
|
git init
|
||||||
|
git remote add origin $Env:DRONE_REMOTE_URL
|
||||||
|
}
|
||||||
|
|
||||||
|
git fetch $FLAGS origin "+refs/tags/${Env:DRONE_TAG}:"
|
||||||
|
git checkout -qf FETCH_HEAD
|
||||||
|
`
|
||||||
|
|
||||||
Reference in New Issue
Block a user