@@ -5,116 +5,107 @@ name: linux_benchmark_pipeline
55# Controls when the action will run.
66# Triggers the workflow on push or pull request
77# events but only for the devel branch
8- on :
9- pull_request_target :
10- types : [opened, reopened, synchronize]
11- branches :
12- - devel
13- - main
14- paths :
15- - ' **.yml'
16- - ' **.sh'
17- - ' **.j2'
18- - ' **.ps1'
19- - ' **.cfg'
8+ on : # yamllint disable-line rule:truthy
9+ pull_request_target :
10+ types : [opened, reopened, synchronize]
11+ branches :
12+ - devel
13+ - main
14+ paths :
15+ - ' **.yml'
16+ - ' **.sh'
17+ - ' **.j2'
18+ - ' **.ps1'
19+ - ' **.cfg'
2020
2121# A workflow run is made up of one or more jobs
2222# that can run sequentially or in parallel
2323jobs :
2424 # This will create messages for first time contributers and direct them to the Discord server
25- welcome :
26- runs-on : ubuntu-latest
27-
28- steps :
29- - uses : actions/first-interaction@v1.1.0
30- with :
31- repo-token : ${{ secrets.GITHUB_TOKEN }}
32- pr-message : |-
33- Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
34- Please join in the conversation happening on the [Discord Server](https://discord.gg/JFxpSgPFEJ ) as well.
25+ welcome :
26+ runs-on : ubuntu-latest
27+
28+ steps :
29+ - uses : actions/first-interaction@main
30+ with :
31+ repo-token : ${{ secrets.GITHUB_TOKEN }}
32+ pr-message : |-
33+ Congrats on opening your first pull request and thank you for taking the time to help improve Ansible-Lockdown!
34+ Please join in the conversation happening on the [Discord Server](https://discord.io/ansible-lockdown ) as well.
3535 # This workflow contains a single job called "build"
36- build :
37- # The type of runner that the job will run on
38- runs-on : ubuntu-latest
39-
40- env :
41- ENABLE_DEBUG : false
42-
43- # Steps represent a sequence of tasks that will be executed as part of the job
44- steps :
45- # Checks-out your repository under $GITHUB_WORKSPACE,
46- # so your job can access it
47- - uses : actions/checkout@v2
48- with :
49- ref : ${{ github.event.pull_request.head.sha }}
50-
51- - name : Add_ssh_key
52- working-directory : .github/workflows
53- env :
54- SSH_AUTH_SOCK : /tmp/ssh_agent.sock
55- PRIVATE_KEY : " ${{ secrets.SSH_PRV_KEY }}"
56- run : |
57- mkdir .ssh
58- chmod 700 .ssh
59- echo $PRIVATE_KEY > .ssh/github_actions.pem
60- chmod 600 .ssh/github_actions.pem
61-
62- # ## Build out the server
63- - name : Terraform_Init
64- working-directory : .github/workflows
65- run : terraform init
66-
67- - name : Terraform_Validate
68- working-directory : .github/workflows
69- run : terraform validate
70-
71- - name : Terraform_Apply
72- working-directory : .github/workflows
73- env :
74- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
75- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
76- run : terraform apply -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
77-
78- # # Debug Section
79- - name : DEBUG - Show Ansible hostfile
80- if : env.ENABLE_DEBUG == 'true'
81- working-directory : .github/workflows
82- run : cat hosts.yml
83-
84- # Centos 7 images take a while to come up insert sleep or playbook fails
85-
86- - name : Check if test os is rhel7
87- working-directory : .github/workflows
88- id : test_os
89- run : >-
90- echo "::set-output name=RHEL7::$(
91- grep -c RHEL7 OS.tfvars
92- )"
93-
94- - name : if RHEL7 - Sleep for 60 seconds
95- if : steps.test_os.outputs.RHEL7 >= 1
96- run : sleep 60s
97- shell : bash
98-
99- # Run the ansible playbook
100- - name : Run_Ansible_Playbook
101- uses : arillso/action.playbook@master
102- with :
103- playbook : site.yml
104- inventory : .github/workflows/hosts.yml
105- galaxy_file : collections/requirements.yml
106- private_key : ${{ secrets.SSH_PRV_KEY }}
107- # verbose: 3
108- env :
109- ANSIBLE_HOST_KEY_CHECKING : " false"
110- ANSIBLE_DEPRECATION_WARNINGS : " false"
111-
112- # Remove test system - User secrets to keep if necessary
36+ build :
37+ # The type of runner that the job will run on
38+ runs-on : ubuntu-latest
11339
114- - name : Terraform_Destroy
115- working-directory : .github/workflows
116- if : always() && env.ENABLE_DEBUG == 'false'
11740 env :
118- AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
119- AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
120- run : terraform destroy -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
41+ ENABLE_DEBUG : false
42+
43+ # Steps represent a sequence of tasks that will be executed as part of the job
44+ steps :
45+ # Checks-out your repository under $GITHUB_WORKSPACE,
46+ # so your job can access it
47+ - uses : actions/checkout@v3
48+ with :
49+ ref : ${{ github.event.pull_request.head.sha }}
50+
51+ - name : Add_ssh_key
52+ working-directory : .github/workflows
53+ env :
54+ SSH_AUTH_SOCK : /tmp/ssh_agent.sock
55+ PRIVATE_KEY : " ${{ secrets.SSH_PRV_KEY }}"
56+ run : |
57+ mkdir .ssh
58+ chmod 700 .ssh
59+ echo $PRIVATE_KEY > .ssh/github_actions.pem
60+ chmod 600 .ssh/github_actions.pem
61+
62+ # ## Build out the server
63+ - name : Terraform_Init
64+ working-directory : .github/workflows
65+ run : terraform init
66+
67+ - name : Terraform_Validate
68+ working-directory : .github/workflows
69+ run : terraform validate
70+
71+ - name : Terraform_Apply
72+ working-directory : .github/workflows
73+ env :
74+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
75+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
76+ run : terraform apply -var-file "OS.tfvars" -var-file "github_vars.tfvars" --auto-approve -input=false
77+
78+ # # Debug Section
79+ - name : DEBUG - Show Ansible hostfile
80+ if : env.ENABLE_DEBUG == 'true'
81+ working-directory : .github/workflows
82+ run : cat hosts.yml
83+
84+ # Aws deployments taking a while to come up insert sleep or playbook fails
85+
86+ - name : Sleep for 60 seconds
87+ run : sleep 60s
88+ shell : bash
89+
90+ # Run the ansible playbook
91+ - name : Run_Ansible_Playbook
92+ uses : arillso/action.playbook@master
93+ with :
94+ playbook : site.yml
95+ inventory : .github/workflows/hosts.yml
96+ galaxy_file : collections/requirements.yml
97+ private_key : ${{ secrets.SSH_PRV_KEY }}
98+ # verbose: 3
99+ env :
100+ ANSIBLE_HOST_KEY_CHECKING : " false"
101+ ANSIBLE_DEPRECATION_WARNINGS : " false"
102+
103+ # Remove test system - User secrets to keep if necessary
104+
105+ - name : Terraform_Destroy
106+ working-directory : .github/workflows
107+ if : always() && env.ENABLE_DEBUG == 'false'
108+ env :
109+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
110+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
111+ run : terraform destroy -var-file "github_vars.tfvars" -var-file "OS.tfvars" --auto-approve -input=false
0 commit comments