-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (48 loc) · 2.07 KB
/
jenkins-ami.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
name: Build Jenkins AMI
on:
push:
branches:
- main
jobs:
buildAmi:
if: github.repository == 'RamaRaju-personal-org/ami-jenkins' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup `packer`
uses: hashicorp/setup-packer@main
id: setup
with:
version: "latest"
- name: Packer format
id: fmt
run: "packer fmt ."
- name: Packer init
id: init
run: "packer init ."
- name: Validate Packer template
run: packer validate .
- name: Prepare JCasC file to change user credientials
run: |
sed -i "s|ADMIN_USER|${{ secrets.JENKINS_ADMIN_USER }}|g" jenkins/jenkins.yaml
sed -i "s|ADMIN_PASSWORD|${{ secrets.JENKINS_ADMIN_PASSWORD }}|g" jenkins/jenkins.yaml
sed -i "s|docker_hub_username|${{ secrets.docker_hub_username }}|g" jenkins/jenkins.yaml
sed -i "s|docker_hub_password|${{ secrets.docker_hub_password }}|g" jenkins/jenkins.yaml
sed -i "s|jenkins_ami_git_url|${{ secrets.GIT_JENKINS_AMI_REPO_URL }}|g" jenkins/build-docker-image.groovy
sed -i "s|git_username|${{ secrets.git_username }}|g" jenkins/jenkins.yaml
sed -i "s|GITHUB_TOKEN|${{ secrets.GIT_TOKEN }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_ACCESS_KEY_ID}|${{ secrets.AWS_ACCESS_KEY_ID }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_SECRET_ACCESS_KEY}|${{ secrets.AWS_SECRET_ACCESS_KEY }}|g" jenkins/jenkins.yaml
sed -i "s|\${AWS_ACCESS_KEY_ID}|${{ secrets.AWS_ACCESS_KEY_ID }}|g" scripts/install.sh
sed -i "s|\${AWS_SECRET_ACCESS_KEY}|${{ secrets.AWS_SECRET_ACCESS_KEY }}|g" scripts/install.sh
shell: bash
- name: Build AMI
run: |
pwd
ls -al
packer build .