Skip to content

feat: script update #190

feat: script update

feat: script update #190

Workflow file for this run

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 .