This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b407c65
commit 28356c3
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy Bundle | ||
on: [push] | ||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
Deploy-Bundle: | ||
name: Deploy Bundle | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- name: Install Deployment Tools | ||
run: wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg && echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list && sudo apt-get update && sudo apt-get install -y ansible terraform | ||
- name: Versions | ||
run: ansible --version && terraform --version | ||
- name: Create SSH Key | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ssh_priv: ${{ secrets.SSH_PRIV_KEY }} | ||
REPO: ${{ github.event.repository.name }} | ||
if: ${{ env.ssh_priv == '' }} | ||
run: ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N "" && cp ~/.ssh/id_rsa.pub deploy_bundle/pub_key #&& cat ~/.ssh/id_rsa | gh secret -R $GITHUB_REPOSITORY set SSH_PRIV_KEY | ||
- name: Terraform Init | ||
run: cd deploy_bundle && terraform init && ls -a -l | ||
- name: Get Google Cloud Platform Credentials | ||
env: | ||
GCP_CREDS: ${{ secrets.GCP_CREDS }} | ||
run: cd deploy_bundle && echo $GCP_CREDS > gcp_creds.json | ||
- name: Terraform Plan | ||
run: cd deploy_bundle && terraform plan | ||
- name: Terraform Apply | ||
run: cd deploy_bundle && terraform apply -auto-approve | ||
- name: Commit Terraform State File | ||
run: | | ||
cd deploy_bundle | ||
git add *.tfstate | ||
git config user.name "Deploy Bundle Action" --global | ||
git config user.email "github-actions[bot]@users.noreply.github.com" --global | ||
git commit --message "Commit State File" | ||
git push | ||
- name: Generate Ansible Configuration | ||
run: | | ||
cd deploy_bundle | ||
python3 ansible.py | ||
- name: Run Ansible Playbook | ||
run: | | ||
cd deploy_bundle | ||
ansible-playbook nginx.yml | ||