-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (118 loc) · 5.53 KB
/
github_workflows_build.yml
File metadata and controls
139 lines (118 loc) · 5.53 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
# This workflow automatically deploys to GitHub Pages using GitHub Actions
# No manual configuration needed - it handles everything!
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
- name: Cache winget-pkgs repo
uses: actions/cache@v4
id: cache-winget
with:
path: winget-pkgs
key: winget-pkgs-${{ github.run_id }}
restore-keys: |
winget-pkgs-
- name: Checkout winget-pkgs repo
if: steps.cache-winget.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: microsoft/winget-pkgs
path: winget-pkgs
fetch-depth: 1
- name: Update winget-pkgs if cached
if: steps.cache-winget.outputs.cache-hit == 'true'
run: |
cd winget-pkgs
git fetch origin
git reset --hard origin/master
- 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: Copy site assets
run: |
# Create a deployment directory
mkdir -p deploy
# Copy files (overwrite if exists)
cp index.html deploy/
cp packages.json deploy/
# Create .nojekyll to prevent Jekyll processing
touch deploy/.nojekyll
# Create a simple 404 page
echo '<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=/winget-search/"></head></html>' > deploy/404.html
# Create a CNAME file if you're using a custom domain
# echo "your-custom-domain.com" > deploy/CNAME
- 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: Wait for deployment
run: |
echo "Deployment complete. GitHub Pages will update within a few minutes."
echo "If using a custom domain, it may take longer due to CDN caching."
- 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
echo "Visit the site at: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/" >> $GITHUB_STEP_SUMMARY