docker: use python for docker-update-hosts #1719
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: CI | |
on: | |
push: | |
paths-ignore: | |
- '.github/**' | |
- '*.md' | |
- '.gitignore' | |
- 'roles/backup/**' | |
- 'roles/backup2/**' | |
- 'roles/restore/**' | |
- 'roles/settings/**' | |
- 'roles/nvidia/**' | |
- 'roles/plex_extra_tasks/**' | |
- 'roles/plex_auth_token/**' | |
- 'roles/plex_db/**' | |
- 'roles/arr_db/**' | |
pull_request: | |
paths-ignore: | |
- '.github/**' | |
- '*.md' | |
- '.gitignore' | |
- 'roles/backup/**' | |
- 'roles/backup2/**' | |
- 'roles/restore/**' | |
- 'roles/settings/**' | |
- 'roles/nvidia/**' | |
- 'roles/plex_extra_tasks/**' | |
- 'roles/plex_auth_token/**' | |
- 'roles/plex_db/**' | |
- 'roles/arr_db/**' | |
workflow_dispatch: | |
jobs: | |
ansible-lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install packages | |
run: pip install "ansible>=9.0.0,<10.0.0" ansible-lint==6.22.2 jmespath | |
- name: Run ansible linter | |
run: ansible-lint | |
- name: Run salty linter | |
run: python3 ./scripts/salty-linter.py ./roles | |
add-contributors: | |
runs-on: ubuntu-22.04 | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: BobAnkh/add-contributors@master | |
with: | |
REPO_NAME: 'saltyorg/Saltbox' | |
CONTRIBUTOR: '### Contributors' | |
COLUMN_PER_ROW: '6' | |
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
IMG_WIDTH: '100' | |
FONT_SIZE: '14' | |
PATH: '/README.md' | |
COMMIT_MESSAGE: 'docs(README): update contributors' | |
AVATAR_SHAPE: 'square' | |
find-roles: | |
runs-on: ubuntu-22.04 | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- uses: actions/checkout@v4 | |
- id: set-matrix | |
run: echo "matrix={\"roles\":[$(awk '/# Core/{flag=1;next}/# Apps End/{flag=0}flag' saltbox.yml | awk '!/#/' | awk -F'[][]' '{print $2}' | tr '\n' ',' | sed 's/,*$//' | awk -F',' '{ for( i=1; i<=NF; i++ ) print $i }' | awk '{ gsub(/ /,""); print }'| sort -u | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/' | sed "s/.\(roles\|common\|hetzner\|kernel\|motd\|mounts\|nvidia\|preinstall\|rclone\|scripts\|shell\|system\|traefik\|traefik-reset-certs\|user\|cloudflare\|plex-db\|arr-db\|ddns\).,//g")]}" >> $GITHUB_OUTPUT | |
install: | |
name: '${{ matrix.roles }}' | |
runs-on: ubuntu-22.04 | |
needs: [ansible-lint, find-roles] | |
strategy: | |
matrix: ${{ fromJson(needs.find-roles.outputs.matrix) }} | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create /srv/ansible | |
run: sudo mkdir /srv/ansible | |
- name: Install Dependencies | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 10 | |
max_attempts: 3 | |
shell: bash | |
command: curl https://raw.githubusercontent.com/saltyorg/sb/master/sb_dep.sh --output sb_dep.sh && sudo bash sb_dep.sh -v && /srv/ansible/venv/bin/ansible --version | |
- name: Create /srv/git | |
run: sudo mkdir /srv/git | |
- name: Symlink cloned repository to /srv/git/saltbox | |
run: sudo ln -s $GITHUB_WORKSPACE /srv/git/saltbox | |
- name: Chown /srv/git | |
run: sudo chown -R runner:runner /srv/git | |
- name: Import default configuration | |
run: for i in defaults/*; do cp -n $i "$(basename "${i%.*}")"; done | |
- name: Edit accounts.yml | |
run: sed -i 's/seed/runner/g' accounts.yml | |
- name: Run Tree | |
run: tree -a | |
- name: Syntax Check | |
run: sudo /srv/ansible/venv/bin/ansible-playbook saltbox.yml --syntax-check | |
- name: Install Saltbox Core | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 30 | |
max_attempts: 3 | |
shell: bash | |
command: sudo /srv/ansible/venv/bin/ansible-playbook saltbox.yml --tags "core" --skip-tags "settings" --extra-vars '{"continuous_integration":true}' | |
if: ${{ !(contains(matrix.roles, 'saltbox') || contains(matrix.roles, 'feederbox') || contains(matrix.roles, 'mediabox') || contains(matrix.roles, 'core')) }} | |
- name: Install ${{ matrix.roles }} | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 30 | |
max_attempts: 3 | |
shell: bash | |
command: sudo /srv/ansible/venv/bin/ansible-playbook saltbox.yml --tags "${{ matrix.roles }}" --skip-tags "settings" --extra-vars '{"continuous_integration":true}' | |
webhook: | |
name: 'webhook' | |
runs-on: self-hosted | |
needs: install | |
if: always() && github.event_name != 'pull_request' && github.event.repository.fork == false | |
steps: | |
- name: Determine Workflow Conclusion | |
run: | | |
max_attempts=5 | |
attempt=0 | |
while [ $attempt -lt $max_attempts ]; do | |
attempt=$((attempt + 1)) | |
echo "Attempt $attempt of $max_attempts" | |
response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs") | |
if [ "$?" -eq 0 ]; then | |
echo "API Request successful." | |
break | |
else | |
echo "API Request failed, retrying in $((attempt * 2)) seconds..." | |
sleep $((attempt * 2)) | |
fi | |
done | |
if [ $attempt -eq $max_attempts ]; then | |
echo "API requests failed after $max_attempts attempts, defaulting to failure." | |
echo "WORKFLOW_CONCLUSION=failure" >> $GITHUB_ENV | |
else | |
conclusions=$(echo "$response" | jq '[.jobs[].conclusion] | unique | .[]') | |
if echo "$conclusions" | grep -q "cancelled"; then | |
echo "Some jobs were cancelled." | |
echo "WORKFLOW_CONCLUSION=cancelled" >> $GITHUB_ENV | |
elif echo "$conclusions" | grep -q "failure"; then | |
echo "Some jobs failed." | |
echo "WORKFLOW_CONCLUSION=failure" >> $GITHUB_ENV | |
elif echo "$conclusions" | grep -q "success"; then | |
echo "All jobs succeeded or were skipped." | |
echo "WORKFLOW_CONCLUSION=success" >> $GITHUB_ENV | |
else | |
echo "Defaulting to failure due to uncertain job conclusions." | |
echo "WORKFLOW_CONCLUSION=failure" >> $GITHUB_ENV | |
fi | |
fi | |
- uses: sarisia/actions-status-discord@v1 | |
with: | |
webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
status: ${{ env.WORKFLOW_CONCLUSION }} |