Skip to content

Commit daf2945

Browse files
feat: improve workflow speed with uv
Signed-off-by: Anatoli Nicolae <an@thundersquared.com> fix: remove unnecessary env: block Signed-off-by: Anatoli Nicolae <an@thundersquared.com>
1 parent 52af919 commit daf2945

File tree

6 files changed

+136
-120
lines changed

6 files changed

+136
-120
lines changed
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy mx1 with Ansible
22
permissions:
33
contents: read
4-
env:
5-
PYTHON_VERSION: '3.14'
64
on:
75
workflow_dispatch:
86
inputs:
@@ -28,27 +26,9 @@ jobs:
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v6.0.2
31-
- name: Set up Python
32-
uses: actions/setup-python@v6.2.0
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
check-latest: true
36-
cache: 'pip'
37-
cache-dependency-path: 'requirements.txt'
38-
- name: Cache Ansible Galaxy requirements
39-
uses: actions/cache@v5.0.3
40-
with:
41-
path: ~/.ansible
42-
key: ansible-galaxy-${{ hashFiles('mx1/ansible/requirements.yml') }}
43-
restore-keys: |
44-
ansible-galaxy-
45-
- name: Install Ansible
46-
run: pip install -r requirements.txt
47-
- name: Install Ansible Galaxy requirements
48-
run: |
49-
ansible-galaxy install -r mx1/ansible/requirements.yml --force-with-deps
50-
- name: Set up inventory with secrets and SSH key
29+
- name: Set up inventory, Python version, and SSH key
5130
run: |
31+
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
5232
if [ -z "${{ secrets.HOST }}" ] || [ -z "${{ secrets.USER }}" ]; then
5333
echo "HOST or USER secret is missing!" >&2
5434
exit 1
@@ -59,10 +39,33 @@ jobs:
5939
chmod 600 ~/.ssh/id_ed25519
6040
ssh-keyscan -H "${{ secrets.HOST }}" >> ~/.ssh/known_hosts
6141
echo "${{ secrets.HOST }} ansible_user=${{ secrets.USER }} ansible_ssh_private_key=~/.ssh/id_ed25519" > inventory
42+
- name: Cache Ansible Galaxy requirements
43+
uses: actions/cache@v5.0.3
44+
with:
45+
path: ~/.ansible
46+
key: ansible-galaxy-${{ hashFiles('mx1/ansible/requirements.yml') }}
47+
restore-keys: |
48+
ansible-galaxy-
49+
- name: Set up Python
50+
uses: actions/setup-python@v6.2.0
51+
with:
52+
python-version-file: '.python-version'
53+
check-latest: true
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7.2.1
56+
with:
57+
enable-cache: true
58+
cache-dependency-glob: 'requirements.txt'
59+
- name: Install Ansible
60+
run: |
61+
uv pip install -r requirements.txt
62+
- name: Install Ansible Galaxy requirements
63+
run: |
64+
uv run ansible-galaxy install -r mx1/ansible/requirements.yml --force-with-deps
6265
- name: Run Ansible Playbook
6366
env:
6467
ANSIBLE_CONFIG: mx1/ansible/ansible.cfg
65-
ANSIBLE_STRATEGY_PLUGINS: ${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
68+
ANSIBLE_STRATEGY_PLUGINS: ${{ github.workspace }}/.venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
6669
BORG_REPOSITORY: ${{ secrets.BORG_REPOSITORY }}
6770
BORG_PASSPHRASE: ${{ secrets.BORG_PASSPHRASE }}
6871
BORG_HEARTBEAT_URL: ${{ secrets.BORG_HEARTBEAT_URL }}
@@ -73,4 +76,4 @@ jobs:
7376
DOCKER_IPV6_SUBNET: ${{ secrets.DOCKER_IPV6_SUBNET }}
7477
SCHEDULED_RUN: ${{ github.event_name == 'schedule' || github.event.inputs.force_schedule_mode == 'true' }}
7578
run: |
76-
ansible-playbook -i inventory mx1/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
79+
uv run ansible-playbook -i inventory mx1/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy web1 with Ansible
22
permissions:
33
contents: read
4-
env:
5-
PYTHON_VERSION: '3.14'
64
on:
75
workflow_dispatch:
86
inputs:
@@ -28,27 +26,9 @@ jobs:
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v6.0.2
31-
- name: Set up Python
32-
uses: actions/setup-python@v6.2.0
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
check-latest: true
36-
cache: 'pip'
37-
cache-dependency-path: 'requirements.txt'
38-
- name: Cache Ansible Galaxy requirements
39-
uses: actions/cache@v5.0.3
40-
with:
41-
path: ~/.ansible
42-
key: ansible-galaxy-${{ hashFiles('web1/ansible/requirements.yml') }}
43-
restore-keys: |
44-
ansible-galaxy-
45-
- name: Install Ansible
46-
run: pip install -r requirements.txt
47-
- name: Install Ansible Galaxy requirements
48-
run: |
49-
ansible-galaxy install -r web1/ansible/requirements.yml --force-with-deps
50-
- name: Set up inventory with secrets and SSH key
29+
- name: Set up inventory, Python version, and SSH key
5130
run: |
31+
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
5232
if [ -z "${{ secrets.HOST }}" ] || [ -z "${{ secrets.USER }}" ]; then
5333
echo "HOST or USER secret is missing!" >&2
5434
exit 1
@@ -59,15 +39,38 @@ jobs:
5939
chmod 600 ~/.ssh/id_ed25519
6040
ssh-keyscan -H "${{ secrets.HOST }}" >> ~/.ssh/known_hosts
6141
echo "${{ secrets.HOST }} ansible_user=${{ secrets.USER }} ansible_ssh_private_key=~/.ssh/id_ed25519" > inventory
42+
- name: Cache Ansible Galaxy requirements
43+
uses: actions/cache@v5.0.3
44+
with:
45+
path: ~/.ansible
46+
key: ansible-galaxy-${{ hashFiles('web1/ansible/requirements.yml') }}
47+
restore-keys: |
48+
ansible-galaxy-
49+
- name: Set up Python
50+
uses: actions/setup-python@v6.2.0
51+
with:
52+
python-version-file: '.python-version'
53+
check-latest: true
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7.2.1
56+
with:
57+
enable-cache: true
58+
cache-dependency-glob: 'requirements.txt'
59+
- name: Install Ansible
60+
run: |
61+
uv pip install -r requirements.txt
62+
- name: Install Ansible Galaxy requirements
63+
run: |
64+
uv run ansible-galaxy install -r web1/ansible/requirements.yml --force-with-deps
6265
- name: Run Ansible Playbook
6366
env:
6467
ANSIBLE_CONFIG: web1/ansible/ansible.cfg
65-
ANSIBLE_STRATEGY_PLUGINS: ${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
68+
ANSIBLE_STRATEGY_PLUGINS: .venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
6669
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
6770
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
6871
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
6972
DOCKER_IPV6_SUBNET: ${{ secrets.DOCKER_IPV6_SUBNET }}
7073
CROWDSEC_TOKEN: ${{ secrets.CROWDSEC_TOKEN }}
7174
SCHEDULED_RUN: ${{ github.event_name == 'schedule' || github.event.inputs.force_schedule_mode == 'true' }}
7275
run: |
73-
ansible-playbook -i inventory web1/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
76+
uv run ansible-playbook -i inventory web1/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy web2 with Ansible
22
permissions:
33
contents: read
4-
env:
5-
PYTHON_VERSION: '3.14'
64
on:
75
workflow_dispatch:
86
inputs:
@@ -28,27 +26,9 @@ jobs:
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v6.0.2
31-
- name: Set up Python
32-
uses: actions/setup-python@v6.2.0
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
check-latest: true
36-
cache: 'pip'
37-
cache-dependency-path: 'requirements.txt'
38-
- name: Cache Ansible Galaxy requirements
39-
uses: actions/cache@v5.0.3
40-
with:
41-
path: ~/.ansible
42-
key: ansible-galaxy-${{ hashFiles('web2/ansible/requirements.yml') }}
43-
restore-keys: |
44-
ansible-galaxy-
45-
- name: Install Ansible
46-
run: pip install -r requirements.txt
47-
- name: Install Ansible Galaxy requirements
48-
run: |
49-
ansible-galaxy install -r web2/ansible/requirements.yml --force-with-deps
50-
- name: Set up inventory with secrets and SSH key
29+
- name: Set up inventory, Python version, and SSH key
5130
run: |
31+
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
5232
if [ -z "${{ secrets.HOST }}" ] || [ -z "${{ secrets.USER }}" ]; then
5333
echo "HOST or USER secret is missing!" >&2
5434
exit 1
@@ -59,14 +39,37 @@ jobs:
5939
chmod 600 ~/.ssh/id_ed25519
6040
ssh-keyscan -H "${{ secrets.HOST }}" >> ~/.ssh/known_hosts
6141
echo "${{ secrets.HOST }} ansible_user=${{ secrets.USER }} ansible_ssh_private_key=~/.ssh/id_ed25519" > inventory
42+
- name: Cache Ansible Galaxy requirements
43+
uses: actions/cache@v5.0.3
44+
with:
45+
path: ~/.ansible
46+
key: ansible-galaxy-${{ hashFiles('web2/ansible/requirements.yml') }}
47+
restore-keys: |
48+
ansible-galaxy-
49+
- name: Set up Python
50+
uses: actions/setup-python@v6.2.0
51+
with:
52+
python-version-file: '.python-version'
53+
check-latest: true
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7.2.1
56+
with:
57+
enable-cache: true
58+
cache-dependency-glob: 'requirements.txt'
59+
- name: Install Ansible
60+
run: |
61+
uv pip install -r requirements.txt
62+
- name: Install Ansible Galaxy requirements
63+
run: |
64+
uv run ansible-galaxy install -r web2/ansible/requirements.yml --force-with-deps
6265
- name: Run Ansible Playbook
6366
env:
6467
ANSIBLE_CONFIG: web2/ansible/ansible.cfg
65-
ANSIBLE_STRATEGY_PLUGINS: ${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
68+
ANSIBLE_STRATEGY_PLUGINS: ${{ github.workspace }}/.venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
6669
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
6770
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
6871
DOCKER_IPV6_SUBNET: ${{ secrets.DOCKER_IPV6_SUBNET }}
6972
CROWDSEC_TOKEN: ${{ secrets.CROWDSEC_TOKEN }}
7073
SCHEDULED_RUN: ${{ github.event_name == 'schedule' || github.event.inputs.force_schedule_mode == 'true' }}
7174
run: |
72-
ansible-playbook -i inventory web2/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
75+
uv run ansible-playbook -i inventory web2/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy web3 with Ansible
22
permissions:
33
contents: read
4-
env:
5-
PYTHON_VERSION: '3.14'
64
on:
75
workflow_dispatch:
86
inputs:
@@ -28,27 +26,9 @@ jobs:
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v6.0.2
31-
- name: Set up Python
32-
uses: actions/setup-python@v6.2.0
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
check-latest: true
36-
cache: 'pip'
37-
cache-dependency-path: 'requirements.txt'
38-
- name: Cache Ansible Galaxy requirements
39-
uses: actions/cache@v5.0.3
40-
with:
41-
path: ~/.ansible
42-
key: ansible-galaxy-${{ hashFiles('web3/ansible/requirements.yml') }}
43-
restore-keys: |
44-
ansible-galaxy-
45-
- name: Install Ansible
46-
run: pip install -r requirements.txt
47-
- name: Install Ansible Galaxy requirements
48-
run: |
49-
ansible-galaxy install -r web3/ansible/requirements.yml --force-with-deps
50-
- name: Set up inventory with secrets and SSH key
29+
- name: Set up inventory, Python version, and SSH key
5130
run: |
31+
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
5232
if [ -z "${{ secrets.HOST }}" ] || [ -z "${{ secrets.USER }}" ]; then
5333
echo "HOST or USER secret is missing!" >&2
5434
exit 1
@@ -59,10 +39,33 @@ jobs:
5939
chmod 600 ~/.ssh/id_ed25519
6040
ssh-keyscan -H "${{ secrets.HOST }}" >> ~/.ssh/known_hosts
6141
echo "${{ secrets.HOST }} ansible_user=${{ secrets.USER }} ansible_ssh_private_key=~/.ssh/id_ed25519" > inventory
42+
- name: Cache Ansible Galaxy requirements
43+
uses: actions/cache@v5.0.3
44+
with:
45+
path: ~/.ansible
46+
key: ansible-galaxy-${{ hashFiles('web3/ansible/requirements.yml') }}
47+
restore-keys: |
48+
ansible-galaxy-
49+
- name: Set up Python
50+
uses: actions/setup-python@v6.2.0
51+
with:
52+
python-version-file: '.python-version'
53+
check-latest: true
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7.2.1
56+
with:
57+
enable-cache: true
58+
cache-dependency-glob: 'requirements.txt'
59+
- name: Install Ansible
60+
run: |
61+
uv pip install -r requirements.txt
62+
- name: Install Ansible Galaxy requirements
63+
run: |
64+
uv run ansible-galaxy install -r web3/ansible/requirements.yml --force-with-deps
6265
- name: Run Ansible Playbook
6366
env:
6467
ANSIBLE_CONFIG: web3/ansible/ansible.cfg
65-
ANSIBLE_STRATEGY_PLUGINS: ${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
68+
ANSIBLE_STRATEGY_PLUGINS: ${{ github.workspace }}/.venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
6669
CLOUDFLARED_TOKEN: ${{ secrets.CLOUDFLARED_TOKEN }}
6770
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }}
6871
GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
@@ -71,4 +74,4 @@ jobs:
7174
CROWDSEC_TOKEN: ${{ secrets.CROWDSEC_TOKEN }}
7275
SCHEDULED_RUN: ${{ github.event_name == 'schedule' || github.event.inputs.force_schedule_mode == 'true' }}
7376
run: |
74-
ansible-playbook -i inventory web3/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
77+
uv run ansible-playbook -i inventory web3/ansible/playbook.yml --private-key ~/.ssh/id_ed25519

.github/workflows/web8-ansible-deploy.yml

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
name: Deploy web8 with Ansible
22
permissions:
33
contents: read
4-
env:
5-
PYTHON_VERSION: '3.14'
64
on:
75
workflow_dispatch:
86
inputs:
@@ -28,27 +26,9 @@ jobs:
2826
steps:
2927
- name: Checkout repository
3028
uses: actions/checkout@v6.0.2
31-
- name: Set up Python
32-
uses: actions/setup-python@v6.2.0
33-
with:
34-
python-version: ${{ env.PYTHON_VERSION }}
35-
check-latest: true
36-
cache: 'pip'
37-
cache-dependency-path: 'requirements.txt'
38-
- name: Cache Ansible Galaxy requirements
39-
uses: actions/cache@v5.0.3
40-
with:
41-
path: ~/.ansible
42-
key: ansible-galaxy-${{ hashFiles('web8/ansible/requirements.yml') }}
43-
restore-keys: |
44-
ansible-galaxy-
45-
- name: Install Ansible
46-
run: pip install -r requirements.txt
47-
- name: Install Ansible Galaxy requirements
48-
run: |
49-
ansible-galaxy install -r web8/ansible/requirements.yml --force-with-deps
50-
- name: Set up inventory with secrets and SSH key
29+
- name: Set up inventory, Python version, and SSH key
5130
run: |
31+
echo "PYTHON_VERSION=$(cat .python-version)" >> "$GITHUB_ENV"
5232
if [ -z "${{ secrets.HOST }}" ] || [ -z "${{ secrets.USER }}" ]; then
5333
echo "HOST or USER secret is missing!" >&2
5434
exit 1
@@ -59,10 +39,33 @@ jobs:
5939
chmod 600 ~/.ssh/id_ed25519
6040
ssh-keyscan -H "${{ secrets.HOST }}" >> ~/.ssh/known_hosts
6141
echo "${{ secrets.HOST }} ansible_user=${{ secrets.USER }} ansible_ssh_private_key=~/.ssh/id_ed25519" > inventory
42+
- name: Cache Ansible Galaxy requirements
43+
uses: actions/cache@v5.0.3
44+
with:
45+
path: ~/.ansible
46+
key: ansible-galaxy-${{ hashFiles('web8/ansible/requirements.yml') }}
47+
restore-keys: |
48+
ansible-galaxy-
49+
- name: Set up Python
50+
uses: actions/setup-python@v6.2.0
51+
with:
52+
python-version-file: '.python-version'
53+
check-latest: true
54+
- name: Set up uv
55+
uses: astral-sh/setup-uv@v7.2.1
56+
with:
57+
enable-cache: true
58+
cache-dependency-glob: 'requirements.txt'
59+
- name: Install Ansible
60+
run: |
61+
uv pip install -r requirements.txt
62+
- name: Install Ansible Galaxy requirements
63+
run: |
64+
uv run ansible-galaxy install -r web8/ansible/requirements.yml --force-with-deps
6265
- name: Run Ansible Playbook
6366
env:
6467
ANSIBLE_CONFIG: web8/ansible/ansible.cfg
65-
ANSIBLE_STRATEGY_PLUGINS: ${{ env.pythonLocation }}/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
68+
ANSIBLE_STRATEGY_PLUGINS: ${{ github.workspace }}/.venv/lib/python${{ env.PYTHON_VERSION }}/site-packages/ansible_mitogen/plugins/strategy
6669
CLOUDFLARED_TOKEN: ${{ secrets.CLOUDFLARED_TOKEN }}
6770
BORG_REPOSITORY: ${{ secrets.BORG_REPOSITORY }}
6871
BORG_PASSPHRASE: ${{ secrets.BORG_PASSPHRASE }}
@@ -74,4 +77,4 @@ jobs:
7477
GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }}
7578
SCHEDULED_RUN: ${{ github.event_name == 'schedule' || github.event.inputs.force_schedule_mode == 'true' }}
7679
run: |
77-
ansible-playbook -i inventory web8/ansible/playbook.yml --private-key ~/.ssh/id_ed25519
80+
uv run ansible-playbook -i inventory web8/ansible/playbook.yml --private-key ~/.ssh/id_ed25519

0 commit comments

Comments
 (0)