generated from snow-actions/composite-action-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
83 lines (80 loc) · 2.47 KB
/
action.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Setup Jenkins
description: Set up Jenkins container
author: SnowCait
branding:
icon: circle
color: blue
inputs:
jenkins_image_tag:
description: Jenkins image tag
required: false
default: lts-jdk11
jenkins_home:
description: |
Jenkins home path which will be mounted to /var/jenkins_home.
Set '' if you don't want to mount.
required: false
default: ${{ runner.temp }}/jenkins_home
env_file:
description: Jenkins container env_file path
required: false
runs:
using: composite
steps:
- run: docker version
shell: bash
- run: docker compose version
shell: bash
- name: Set env
run: |
set -x
if [[ "$JENKINS_HOME" == "" ]]; then
echo "JENKINS_HOME=" >> $GITHUB_ENV
else
echo "JENKINS_HOME=$(realpath $JENKINS_HOME)" >> $GITHUB_ENV
fi
echo "JENKINS_URL=http://localhost:8080" >> $GITHUB_ENV
shell: bash
env:
JENKINS_HOME: ${{ inputs.jenkins_home }}
- name: COMPOSE_FILE
run: |
set -x
ACTION_PATH=$(realpath $GITHUB_ACTION_PATH)
COMPOSE_FILE=$ACTION_PATH/compose.yaml
if [[ "$JENKINS_HOME" != "" ]]; then
COMPOSE_FILE=$COMPOSE_FILE:$ACTION_PATH/compose.mount.yaml
fi
if [[ "$ENV_FILE" != "" ]]; then
echo "ENV_FILE=$(realpath $ENV_FILE)" >> $GITHUB_ENV
COMPOSE_FILE=$COMPOSE_FILE:$ACTION_PATH/compose.env.yaml
fi
echo "COMPOSE_FILE=$COMPOSE_FILE" >> $GITHUB_ENV
shell: bash
env:
ENV_FILE: ${{ inputs.env_file }}
- run: |
mkdir -p $JENKINS_HOME
sudo chown -R 1000:1000 $JENKINS_HOME
shell: bash
if: env.JENKINS_HOME != ''
- name: Install JCasC plugins
run: |
if [ -f "$JENKINS_HOME/jenkins.yaml" ]; then
echo 'configuration-as-code' >> $GITHUB_ACTION_PATH/plugins.txt
echo 'configuration-as-code-groovy' >> $GITHUB_ACTION_PATH/plugins.txt
echo 'job-dsl' >> $GITHUB_ACTION_PATH/plugins.txt
fi
shell: bash
- run: cat $GITHUB_ACTION_PATH/plugins.txt
shell: bash
- run: docker compose config
shell: bash
env:
JENKINS_IMAGE_TAG: ${{ inputs.jenkins_image_tag }}
- run: docker compose up -d --wait
shell: bash
env:
JENKINS_IMAGE_TAG: ${{ inputs.jenkins_image_tag }}
- run: echo "JENKINS_VERSION=$(docker compose exec jenkins printenv JENKINS_VERSION)" >> $GITHUB_ENV
shell: bash