Replace embedded template conditionals #47
Workflow file for this run
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
--- | |
name: Ansible Run | |
# on: [push] | |
on: | |
pull_request: | |
types: [opened, synchronize, ready_for_review, edited] | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
inventories: ${{ steps.output-inventories.outputs.inventories }} | |
steps: | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Adding Known Hosts | |
run: ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
- name: Wait for other runs to stop | |
run: | | |
while true; do | |
VM=$(ssh ${{ secrets.SSH_OPTIONS }} -t -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} "ls -l /tmp/run-lock 2>/dev/null | wc -l") | |
if [ "$VM" -gt 0 ]; then | |
echo "Another job is running, waiting 60 seconds..." | |
sleep 60s | |
else | |
ssh ${{ secrets.SSH_OPTIONS }} -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} "touch /tmp/run-lock" | |
break | |
fi | |
done | |
- uses: actions/checkout@v2 | |
- name: Deploy folder | |
run: | | |
ssh ${{ secrets.SSH_OPTIONS }} -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} "mkdir -p ~/${{ github.sha }}" | |
rsync -aH -e "ssh ${{ secrets.SSH_OPTIONS }} -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }}" ./ ${{ secrets.SSH_HOST }}:~/${{ github.sha }}/ | |
- name: output inventories | |
id: output-inventories | |
run: | | |
echo "::set-output name=inventories::$(find examples/inventory-test-* | sort -u | jq -R -s -c 'split("\n")[:-1]')" | |
run: | |
# Run the test inside a centos8 container | |
runs-on: ubuntu-latest | |
needs: setup | |
strategy: | |
fail-fast: false | |
max-parallel: 4 | |
matrix: | |
inventory: ${{fromJSON(needs.setup.outputs.inventories)}} | |
steps: | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Adding Known Hosts | |
run: ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
# Run all inventory files in the repo | |
- name: Run Terrible validation | |
run: | | |
ssh ${{ secrets.SSH_OPTIONS }} -t -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} <<EOF | |
set -e | |
export PY_COLORS=1 | |
export ANSIBLE_FORCE_COLOR=1 | |
cd ~/${{ github.sha }} | |
echo "VALIDATE $inventory ******************************************************************" | |
echo "ansible-playbook -i ${{ matrix.inventory }} -u root main.yml" | |
ansible-playbook -i ${{ matrix.inventory }} -u root main.yml | |
EOF | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
# Run all inventory files in the repo | |
- name: Run Terrible cleanup | |
if: ${{ always() }} | |
run: | | |
ssh ${{ secrets.SSH_OPTIONS }} -t -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} <<EOF | |
set -e | |
export PY_COLORS=1 | |
export ANSIBLE_FORCE_COLOR=1 | |
cd ~/${{ github.sha }} | |
echo "VALIDATE $inventory ******************************************************************" | |
echo "ansible-playbook -i ${{ matrix.inventory }} -u root main.yml --tags purge" | |
ansible-playbook -i ${{ matrix.inventory }} -u root main.yml --tags purge | |
EOF | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
cleanup: | |
# Run the test inside a centos8 container | |
runs-on: ubuntu-latest | |
needs: run | |
if: always() | |
steps: | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Adding Known Hosts | |
run: ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
- name: Cleanup Folder | |
run: | | |
ssh ${{ secrets.SSH_OPTIONS }} -p ${{ secrets.SSH_PORT }} -l ${{ secrets.SSH_USER }} ${{ secrets.SSH_HOST }} "rm -rf ~/${{ github.sha }} ~/.terrible ~/.ssh/known_hosts /tmp/run-lock /tmp/*.tfplan" | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' |