-
Notifications
You must be signed in to change notification settings - Fork 7
64 lines (52 loc) · 1.95 KB
/
publish_ansible_collection.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Publish Ansible Galaxy Collection
on:
release:
types: [published]
workflow_dispatch:
jobs:
publish-collection:
runs-on: ubuntu-latest
steps:
- name: Checkout repo content
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install Ansible
run: pip install ansible
- name: Determine Ansible Galaxy version
run: echo "GALAXY_VERSION=$(echo ${{ github.ref_name }} | cut -c2-)" >> $GITHUB_ENV
- name: Update Ansible Galaxy version
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout main
echo "Updating version to ${{ env.GALAXY_VERSION }} in galaxy.yml"
sed -i 's/\(version:\) .*/\1 ${{ env.GALAXY_VERSION }}/g' galaxy.yml
git add galaxy.yml
- name: Update changelog
run: |
python scripts/changelog.py > CHANGELOG.md
git add CHANGELOG.md
- name: Commit changes
run: |
git commit -m "Update galaxy version and changelog for release ${{ env.GALAXY_VERSION }} [skip ci]"
git push origin HEAD:main
- name: Update release tag
run: |
git pull
git tag -f ${{ github.ref_name }}
git push origin HEAD:main
git push origin -f ${{ github.ref_name }}
- name: Build Ansible collection
run: ansible-galaxy collection build
- name: Determine Ansible collection archive name
run: echo "ARTIFACT=itential-deployer-${{ env.GALAXY_VERSION }}.tar.gz" >> $GITHUB_ENV
- name: Publish collection to Ansible Galaxy
env:
ANSIBLE_API_TOKEN: ${{ secrets.ANSIBLE_API_TOKEN }}
run: ansible-galaxy collection publish ${{ env.ARTIFACT }} --token $ANSIBLE_API_TOKEN