This repository was archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 2.15 KB
/
Copy pathbuild.yaml
File metadata and controls
57 lines (49 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: build
# @see https://stackoverflow.com/questions/61891328/trigger-github-action-only-on-new-tags#answer-61892639
on:
push:
tags:
- '**'
jobs:
# @see https://docs.github.com/en/actions/publishing-packages/publishing-docker-images
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# @see https://stackoverflow.com/questions/58033366/how-to-get-the-current-branch-within-github-actions#answer-58034787
# @see https://docs.github.com/en/github-ae@latest/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs
- name: Get variables from pushed tag
id: get_variables
run: |
PHP_VERSION=`echo ${GITHUB_REF#refs/tags/} | sed -r "s/php-(.+)\/deployer-(.+)/\1/"`
DEPLOYER_VERSION=`echo ${GITHUB_REF#refs/tags/} | sed -r "s/php-(.+)\/deployer-(.+)/\2/"`
IMAGE_TAG=$DEPLOYER_VERSION
if [ $PHP_VERSION = '5' ] || [ $PHP_VERSION = '7.0' ]; then
COMPOSER_VERSION=2.2
else
COMPOSER_VERSION=latest
fi
if [[ $DEPLOYER_VERSION =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
DEPLOYER_VERSION=$DEPLOYER_VERSION.*
fi
echo ::set-output name=PHP_VERSION::$PHP_VERSION
echo ::set-output name=COMPOSER_VERSION::$COMPOSER_VERSION
echo ::set-output name=DEPLOYER_VERSION::$DEPLOYER_VERSION
echo ::set-output name=IMAGE_TAG::$IMAGE_TAG
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
build-args: |
PHP_VERSION=${{ steps.get_variables.outputs.PHP_VERSION }}
COMPOSER_VERSION=${{ steps.get_variables.outputs.COMPOSER_VERSION }}
DEPLOYER_VERSION=${{ steps.get_variables.outputs.DEPLOYER_VERSION }}
tags: |
ttskch/deployer:${{ steps.get_variables.outputs.IMAGE_TAG }}
ttskch/deployer:latest
push: true