Skip to content

Commit 6726e96

Browse files
authored
adjustment wf 2 (#13)
1 parent 862aa85 commit 6726e96

File tree

1 file changed

+57
-16
lines changed

1 file changed

+57
-16
lines changed
Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,95 @@
11
name: Publish APT Repository (Signed)
22

33
on:
4-
release:
5-
types: [published, edited]
4+
workflow_run:
5+
workflows: ["Build and Release .deb"]
6+
types: [completed]
67
workflow_dispatch:
78

89
jobs:
910
publish-apt:
1011
runs-on: ubuntu-latest
11-
if: |
12-
startsWith(github.event.release.tag_name, 'v') ||
13-
github.event.release.tag_name == 'Ubuntu-linux'
12+
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
1413

1514
steps:
1615
- name: Checkout
1716
uses: actions/checkout@v4
1817

19-
- name: Download .deb assets from this release
18+
- name: Capturar artifact deb-package (somente workflow_run)
19+
if: ${{ github.event_name == 'workflow_run' }}
20+
uses: actions/github-script@v7
21+
id: get-artifacts
22+
with:
23+
script: |
24+
const run_id = context.payload.workflow_run.id;
25+
const { data } = await github.rest.actions.listWorkflowRunArtifacts({
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
run_id
29+
});
30+
const deb = data.artifacts.find(a => a.name === "deb-package");
31+
if (!deb) {
32+
core.setFailed("Artifact 'deb-package' não encontrado neste run.");
33+
return;
34+
}
35+
core.setOutput("artifact_id", deb.id.toString());
36+
37+
- name: Baixar artifact via API (somente workflow_run)
38+
if: ${{ github.event_name == 'workflow_run' }}
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
run: |
42+
set -e
43+
ART_ID="${{ steps.get-artifacts.outputs.artifact_id }}"
44+
mkdir -p _artifact && cd _artifact
45+
curl -L -H "Authorization: Bearer $GITHUB_TOKEN" \
46+
-H "Accept: application/vnd.github+json" \
47+
-o artifact.zip \
48+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/artifacts/${ART_ID}/zip"
49+
unzip artifact.zip -d deb-package
50+
cd ..
51+
52+
- name: Download .deb do release Ubuntu-linux (somente manual)
53+
if: ${{ github.event_name == 'workflow_dispatch' }}
2054
uses: robinraju/release-downloader@v1
2155
with:
2256
repository: ${{ github.repository }}
23-
tag: ${{ github.event.release.tag_name }}
57+
tag: Ubuntu-linux
2458
fileName: "*.deb"
2559
out-file-path: repo/pool/main/
2660

61+
- name: Organizar .deb em repo/pool/main
62+
run: |
63+
mkdir -p repo/pool/main
64+
shopt -s globstar nullglob
65+
for f in _artifact/deb-package/**/*.deb repo/pool/main/**/*.deb; do
66+
[ -f "$f" ] && cp -v "$f" repo/pool/main/ || true
67+
done
68+
# Se download manual colocou direto no out-file-path, já está em repo/pool/main
69+
ls -l repo/pool/main || true
70+
2771
- name: Install tools
2872
run: sudo apt-get update && sudo apt-get install -y dpkg-dev gnupg apt-utils
2973

3074
- name: Import GPG key
3175
env:
3276
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
3377
run: |
34-
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
78+
set -e
3579
mkdir -p ~/.gnupg
3680
chmod 700 ~/.gnupg
37-
echo "use-agent" > ~/.gnupg/gpg.conf
38-
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
39-
echo "allow-loopback-pinentry" > ~/.gnupg/gpg-agent.conf
81+
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
82+
printf "use-agent\npinentry-mode loopback\n" > ~/.gnupg/gpg.conf
83+
printf "allow-loopback-pinentry\n" > ~/.gnupg/gpg-agent.conf
4084
echo RELOADAGENT | gpg-connect-agent
4185
gpg --list-secret-keys
4286
4387
- name: Generate signed Release files
4488
env:
4589
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
4690
run: |
91+
set -e
4792
mkdir -p repo/dists/stable/main/binary-amd64
48-
# mover .deb para pool/main, caso release-downloader crie subpastas
49-
mkdir -p repo/pool/main
50-
find repo/pool/main -type f -name "*.deb" || mv repo/pool/main/*/*.deb repo/pool/main/ 2>/dev/null || true
51-
5293
apt-ftparchive packages repo/pool > repo/dists/stable/main/binary-amd64/Packages
5394
gzip -kf repo/dists/stable/main/binary-amd64/Packages
5495
apt-ftparchive release repo/dists/stable > repo/dists/stable/Release
@@ -71,4 +112,4 @@ jobs:
71112
publish_branch: gh-pages
72113
publish_dir: repo
73114
keep_files: true
74-
commit_message: "Update signed APT repo from release ${{ github.event.release.tag_name }}"
115+
commit_message: "Update signed APT repo (trigger: ${{ github.event_name }})"

0 commit comments

Comments
 (0)