Compare commits

..

19 Commits

Author SHA1 Message Date
1180a2a1bf Merge pull request 'merge develop' (#20) from develop into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/20
2021-11-23 22:17:13 +00:00
dc20068bc8 Merge pull request 'Test CI/CD by FAKE PR' (#19) from feature_test_cicd into develop
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/19
2021-11-23 22:14:47 +00:00
f8f8388665 [fix] Cleanup drone scripts
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 23:13:36 +01:00
cb28a8b31a Merge pull request 'PR 'feature_cicd_fix'' (#18) from feature_cicd_fix into develop
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/18
2021-11-23 21:47:18 +00:00
3bc5132764 Merge branch 'develop' into feature_cicd_fix
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 22:45:15 +01:00
3f61272b80 [fix] Cleanup 2021-11-23 22:45:05 +01:00
f9f6cbc02a Merge pull request 'feature_cicd_fix' (#17) from feature_cicd_fix into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/17
2021-11-23 21:40:00 +00:00
89683874f4 Merge branch 'develop' into feature_cicd_fix
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 22:37:59 +01:00
1b7028562c [fix] Added missing variable 2021-11-23 22:37:43 +01:00
f254ef8eba Merge pull request 'Updated 'feature_cicd_fix'' (#16) from feature_cicd_fix into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/16
2021-11-23 21:34:51 +00:00
ec29e7f7fe Merge branch 'develop' into feature_cicd_fix
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 22:32:05 +01:00
bb03f89057 Merge branch 'develop' into feature_cicd_fix
All checks were successful
continuous-integration/drone/push Build is passing
2021-11-23 22:28:03 +01:00
b90b14e271 Merge pull request 'feature_cicd_fix' (#15) from feature_cicd_fix into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/15
2021-11-23 21:11:15 +00:00
065735999d Merge branch 'develop' into feature_cicd_fix
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 22:10:05 +01:00
197cfeba33 [fix] Fix again 2021-11-23 15:43:30 +01:00
6bc615549f Merge pull request '[fix] Publish feature tagged image on PR open' (#11) from feature_cicd_fix into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/11
2021-11-23 14:41:32 +00:00
d8ce78bf0e [fix] Publish feature tagged image on PR open
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2021-11-23 15:39:20 +01:00
1ed108bef3 Merge pull request '[fix] Fixed build_develop step' (#10) from feature_test2 into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/10
2021-11-23 14:33:23 +00:00
b674704a31 Merge pull request '[fix] Fixed image building config.' (#2) from develop into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.pbiernat.dev/docker/nginx-php/pulls/2
2021-11-22 23:30:55 +00:00
3 changed files with 81 additions and 29 deletions

View File

@ -6,10 +6,6 @@ name: Build
steps:
- name: build_release
image: plugins/docker
commands:
- sleep 5
- docker build -t docker.pbiernat.dev/nginx-php .
- docker images | grep nginx-php
when:
event: tag
volumes:
@ -23,10 +19,6 @@ steps:
from_secret: registry_username
DOCKER_PASSWORD:
from_secret: registry_password
commands:
- sleep 5
- docker login docker.pbiernat.dev -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker push docker.pbiernat.dev/nginx-php
when:
event: tag
volumes:
@ -36,13 +28,10 @@ steps:
- name: build_develop
image: plugins/docker
commands:
- sleep 5
- docker build -t docker.pbiernat.dev/nginx-php:dev .
- docker images --format "{{.Repository}}:{{.Tag}}" | grep nginx-php:dev
- ./scripts/drone-build.sh
when:
branch: develop
event:
- pull_request
- push
volumes:
- name: docker-sock
@ -50,20 +39,17 @@ steps:
- name: publish_develop
image: plugins/docker
privileged: true
environment:
DOCKER_USERNAME:
from_secret: registry_username
DOCKER_PASSWORD:
from_secret: registry_password
commands:
- sleep 5
- docker build -t docker.pbiernat.dev/nginx-php:dev .
- docker login docker.pbiernat.dev -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker push docker.pbiernat.dev/nginx-php:dev
- ./scripts/drone-publish.sh
when:
branch: develop
event: push
event:
- push
volumes:
- name: docker-sock
path: /var/run
@ -71,31 +57,31 @@ steps:
- name: build_feature
image: plugins/docker
commands:
- sleep 5
- docker build -t docker.pbiernat.dev/nginx-php:$CI_COMMIT_BRANCH .
- docker images --format "{{.Repository}}:{{.Tag}}" | grep nginx-php:${CI_COMMIT_BRANCH}
- ./scripts/drone-build.sh
when:
branch: feature_*
event: push
branch:
- feature_*
- develop
event:
- push
- pull_request
volumes:
- name: docker-sock
path: /var/run
- name: publish_feature
image: plugins/docker
privileged: true
environment:
DOCKER_USERNAME:
from_secret: registry_username
DOCKER_PASSWORD:
from_secret: registry_password
commands:
- sleep 5
- docker login docker.pbiernat.dev -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker push docker.pbiernat.dev/nginx-php:$CI_COMMIT_BRANCH
- ./scripts/drone-publish.sh
when:
branch: feature_*
event: push
branch: develop
event:
- pull_request
volumes:
- name: docker-sock
path: /var/run
@ -111,3 +97,4 @@ services:
volumes:
- name: docker-sock
temp: {}

36
scripts/drone-build.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
branch=$CI_COMMIT_BRANCH
event=$CI_BUILD_EVENT
source_branch=$DRONE_SOURCE_BRANCH
step_name=$DRONE_STEP_NAME
if { contains "$branch" "feature_" && [ "$event" = push ]; } ; then
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:$branch .
return 0
fi
if { [ "$branch" = develop ] && [ "$event" = pull_request ]; } ; then
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:$source_branch .
return 0
fi
if { [ "$branch" = develop ] && [ "$event" = push ] && [ "$step_name" != build_feature ]; } ; then
sleep 5
docker build -t docker.pbiernat.dev/nginx-php:dev .
return 0
fi

29
scripts/drone-publish.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
contains() {
string="$1"
substring="$2"
if test "${string#*$substring}" != "$string"
then
return 0 # $substring is in $string
else
return 1 # $substring is not in $string
fi
}
branch=$CI_COMMIT_BRANCH
event=$CI_BUILD_EVENT
source_branch=$DRONE_SOURCE_BRANCH
docker login docker.pbiernat.dev -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
if { [ "$branch" = develop ] && [ "$event" = pull_request ]; } ; then
docker push docker.pbiernat.dev/nginx-php:$source_branch
return 0
fi
if { [ "$branch" = develop ] && [ "$event" = push ]; } ; then
docker push docker.pbiernat.dev/nginx-php:dev
return 0
fi