Skip to content

Commit 78a3cc6

Browse files
author
Mafyuh
committedJan 13, 2025
init add cd comment on PR
1 parent dd3bd12 commit 78a3cc6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed
 

‎.forgejo/workflows/CD.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,23 @@ jobs:
163163
ANSIBLE_CONFIG: ansible/ansible.cfg
164164
run: |
165165
ansible-playbook -i ansible/hosts.ini ./ansible/playbooks/deploy-docker.yml \
166-
--extra-vars "target_host=${{ env.target_host }} folder=${{ env.folder }} bw_access_token=${{ secrets.BW_ACCESS_TOKEN }}"
166+
--extra-vars "target_host=${{ env.target_host }} folder=${{ env.folder }} bw_access_token=${{ secrets.BW_ACCESS_TOKEN }}" | tee ansible_output.txt
167+
168+
- name: Post Ansible Output as PR Comment
169+
if: github.event.pull_request.merged == true
170+
uses: https://github.com/actions/github-script@v7
171+
with:
172+
github-token: ${{ secrets.GITHUB_TOKEN }}
173+
script: |
174+
const fs = require('fs');
175+
const output = fs.readFileSync('ansible_output.txt', 'utf8');
176+
const prNumber = context.payload.pull_request.number;
177+
178+
await github.rest.issues.createComment({
179+
owner: context.repo.owner,
180+
repo: context.repo.repo,
181+
issue_number: prNumber,
182+
body: `### Ansible Deployment Output\n\`\`\`\n${output}\n\`\`\``
183+
});
184+
167185

0 commit comments

Comments
 (0)
Please sign in to comment.