Skip to content

Commit

Permalink
CI: reorganize workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
throwaway96 committed Mar 28, 2024
1 parent 2103dd8 commit 7623862
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 142 deletions.
66 changes: 0 additions & 66 deletions .github/workflows/check-results.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: App Submissions
name: 'Package: Lint'

on:
pull_request:
Expand All @@ -13,9 +13,10 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Check out repo
uses: actions/checkout@v4

- name: Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
Expand All @@ -31,25 +32,23 @@ jobs:
- name: Install dependencies
run: |
python3 -m pip install -r ./requirements.txt
sudo apt-get install ./temp/*.deb
sudo apt-get install ./temp/webosbrew-toolbox-*.deb
- name: Check changed packages
id: changed_files
uses: dorny/paths-filter@v3
with:
list-files: shell

filters: |
packages:
- added|modified: 'packages/**'
- name: Lint package information
id: lint_package
if: ${{ steps.changed_files.outputs.packages == 'true' }}
run: |
export lint_retcode=0
for changed_file in ${{ steps.changed_files.outputs.packages_files }}; do
echo "## Check Results for $(basename ${changed_file}):" >> /tmp/lint-report.md
echo "## Check Results for $(basename "${changed_file}"):" >> /tmp/lint-report.md
echo >> /tmp/lint-report.md
echo '### Metadata Lint Result' >> /tmp/lint-report.md
Expand All @@ -60,26 +59,29 @@ jobs:
ipkfile=/tmp/$(sha256sum "${changed_file}" | cut -d ' ' -f 1).ipk
python3 -m repogen.downloadipk -i "${changed_file}" -o "${ipkfile}"
echo '### Compatibility Check Results' >> /tmp/lint-report.md
python3 -m repogen.check_compat -i "${changed_file}" -p "${ipkfile}" >> /tmp/lint-report.md || export lint_retcode=1
done
exit ${lint_retcode}
- name: Save Issue Number
- name: Save issue number
# Skip on act or when previous step cancelled
if: ${{ !env.ACT && (success() || failure()) }}
run: echo $ISSUE_NUMBER > /tmp/issue-number.txt
env:
ISSUE_NUMBER: ${{ github.event.number }}
run: echo '${{ github.event.number }}' > /tmp/issue-number.txt

- name: Upload Check Results
- name: Upload lint results
# Skip on act or when previous step cancelled
if: ${{ !env.ACT && (success() || failure()) }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Check Results
name: lint-results
path: |
/tmp/lint-report.md
/tmp/issue-number.txt
- name: Print Check Results (Local)
- name: Print lint results (local)
# Only run on act when previous steps not cancelled
if: ${{ env.ACT && (success() || failure()) }}
run: cat /tmp/lint-report.md
63 changes: 63 additions & 0 deletions .github/workflows/package-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This is a separate workflow due to permission issues.

name: 'Package: Report results'

on:
workflow_run:
workflows: ['Package: Lint']
types: [completed]

# Disable all permissions
permissions: {}

jobs:
report_results:
name: Check results
runs-on: ubuntu-latest
permissions:
actions: read
pull-requests: write
contents: read # Only needed for private repository
issues: read # Only needed for private repository

if: github.event.workflow_run.conclusion != 'skipped'

steps:
- id: extract_lint_results
name: Download and extract artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api "$url" > "$name.zip"
unzip -d "$name" "$name.zip"
done
echo "issue-number=$(cat 'lint-results/issue-number.txt')" >> $GITHUB_OUTPUT
delimiter="$(openssl rand -hex 16)"
echo "content<<${delimiter}" >> "${GITHUB_OUTPUT}"
cat 'lint-results/lint-report.md' >> "${GITHUB_OUTPUT}"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
- id: find_comment
name: Find lint results comment
uses: peter-evans/find-comment@v3
with:
issue-number: ${{ steps.extract_lint_results.outputs.issue-number }}
comment-author: 'github-actions[bot]'
body-includes: 'Check Result'

- name: Report lint results
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.find_comment.outputs.comment-id }}
issue-number: ${{ steps.extract_lint_results.outputs.issue-number }}
body: ${{ steps.extract_lint_results.outputs.content }}
edit-mode: replace
39 changes: 39 additions & 0 deletions .github/workflows/site-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Site: Deploy'

on:
push:
branches:
- main
schedule:
# Run at 41 minutes past every 3rd hour
- cron: 41 */3 * * *
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
generate:
uses: ./.github/workflows/site-generate.yml

deploy:
needs: generate
runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
name: repo site generator
# Shared job for generating the site and uploading as an artifact.
# Does not deploy to Pages.

on:
push:
branches:
- main
schedule:
- cron: 41 */3 * * *
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
name: 'Site: Generate'

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
on:
workflow_call:

jobs:
deploy:
generate:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/checkout@v4
- name: Check out repo
uses: actions/checkout@v4
with:
submodules: true

Expand All @@ -39,7 +24,7 @@ jobs:
path: ./cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('packages/*') }}

- name: Setup Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
Expand All @@ -53,12 +38,7 @@ jobs:
- name: Generate site content
run: invoke build

- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'output'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
13 changes: 13 additions & 0 deletions .github/workflows/site-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Site: Lint'

on:
pull_request:
branches:
- main
paths-ignore:
- 'packages/**'
workflow_dispatch:

jobs:
generate:
uses: ./.github/workflows/site-generate.yml
30 changes: 0 additions & 30 deletions .github/workflows/sitegen-check.yml

This file was deleted.

0 comments on commit 7623862

Please sign in to comment.