Repository navigation
122 lines (105 loc) · 4.83 KB
/
Copy pathgithub_workflows_build.yml
File metadata and controls
122 lines (105 loc) · 4.83 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build and Deploy
on:
push:
branches: [main, master]
schedule:
# Run daily at 2 AM UTC to get fresh package data
- cron: '0 2 * * *'
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
# Pages must be enabled for gh-pages; publication follows this build separately.
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set UTC cache date
id: cache-date
run: echo "date=$(date -u +%F)" >> "$GITHUB_OUTPUT"
- name: Cache winget-pkgs repo
uses: actions/cache@v4
id: cache-winget
with:
path: winget-pkgs
key: winget-pkgs-v2-${{ runner.os }}-${{ steps.cache-date.outputs.date }}
restore-keys: |
winget-pkgs-v2-${{ runner.os }}-
# Always fetch, even on exact hits. Checkout resolves the upstream default branch.
- name: Checkout winget-pkgs repo
uses: actions/checkout@v4
with:
repository: microsoft/winget-pkgs
path: winget-pkgs
fetch-depth: 1
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Extract packages.json
run: |
python extract_packages.py winget-pkgs/manifests/ packages.json
# Verify the output
if [ ! -f packages.json ]; then
echo "Error: packages.json was not created"
exit 1
fi
# Check file size (should be at least 1MB for ~30k packages)
size=$(stat -c%s packages.json)
if [ $size -lt 1000000 ]; then
echo "Warning: packages.json seems too small (${size} bytes)"
cat packages.json | head -50
fi
echo "Successfully created packages.json (${size} bytes)"
- name: Build site assets and metadata
run: python build_site.py --output-dir deploy
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
# GITHUB_TOKEN is automatically provided by GitHub Actions
# No personal access token needed!
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./deploy
publish_branch: gh-pages
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy to GitHub Pages - ${{ github.run_number }}'
# Force push to ensure GitHub Pages detects changes
keep_files: false
# Add .nojekyll to bypass Jekyll processing
enable_jekyll: false
# This action automatically:
# - Creates the gh-pages branch if it doesn't exist
# - Pushes the built site to that branch
# - GitHub Pages automatically serves from this deployment
- name: Report publication status
run: |
echo "Built files pushed to gh-pages. Check the separate Pages publication before verifying the live site."
- name: Create deployment summary
if: success()
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ✅ Success" >> $GITHUB_STEP_SUMMARY
echo "- **Packages extracted**: $(jq '.metadata.total // length' packages.json)" >> $GITHUB_STEP_SUMMARY
echo "- **File size**: $(stat -c%s packages.json | numfmt --to=iec-i --suffix=B)" >> $GITHUB_STEP_SUMMARY
echo "- **Run number**: ${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
python -c 'import json; print("Visit the site at: " + json.load(open("site_config.json"))["public_base_url"])' >> "$GITHUB_STEP_SUMMARY"