Merge pull request #4 from t0m3kz/test-1 #52
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: Deploy configuration | |
on: | |
- push | |
jobs: | |
deploy: | |
name: Validate data | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check out code repo | |
uses: actions/checkout@v4 | |
with: | |
repository: t0m3kz/vyos | |
token: ${{ secrets.TOKEN }} | |
path: vyos | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- name: Install vyos | |
run: | | |
pip install poetry yamllint | |
poetry config virtualenvs.create true | |
poetry install -C vyos --without dev | |
- name: Run yaml | |
run: | | |
echo "Running validation" | |
yamllint -d "{extends: default, ignore: [.github/, ./vyos/]}" . | |
- name: Run validation | |
env: | |
VYOS_PASSWORD: ${{secrets.VYOS_PASSWORD}} | |
run: | | |
echo "Running validation" | |
poetry run -P vyos validate -i ./inventory.yaml -v | |
- name: Run synchronization | |
if: ${{ github.ref == 'refs/heads/main' }} | |
env: | |
VYOS_PASSWORD: ${{secrets.VYOS_PASSWORD}} | |
id: implement | |
run: | | |
echo "Running synchronization to NTE" | |
poetry run -P vyos sync -i ./inventory.yaml -v -m | |
- name: Archive nornir artifacts | |
continue-on-error: true | |
if: ${{ failure() && steps.implement.conclusion == 'failure' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: execution_logs | |
path: | | |
*.log | |
- name: Rollback config | |
continue-on-error: true | |
if: ${{ failure() && steps.implement.conclusion == 'failure' }} | |
run: | | |
echo "Rolling back config" | |
- name: Checkout wiki documentation | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{github.repository}}.wiki | |
path: docs | |
- name: Generate documentation | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
echo "Generating documentation" | |
poetry run -P vyos document -i ./inventory.yaml -v -m | |
- name: Push to wiki | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
cd docs | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Add changes" && git push |