Skip to content

Commit

Permalink
Switch to reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
joshschmelzle authored Oct 12, 2024
1 parent c519388 commit 7f3ee96
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 120 deletions.
60 changes: 9 additions & 51 deletions .github/workflows/build-and-archive-debian-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,20 @@ on:
pull_request:
paths:
- 'debian/changelog'
env:
debpackagename: wlanpi-core
jobs:
format:
name: Get formatted version for filename
uses: WLAN-Pi/gh-workflows/.github/workflows/get-formatted-version-string.yml@main
sbuild:
name: sbuild ${{ matrix.distro }}+${{ matrix.arch }} pkg
runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}"
needs: format
strategy:
fail-fast: false
matrix:
distro: [bullseye,bookworm]
arch: [arm64]
steps:
# - name: Enable debug logging
# run: echo "Debug logging enabled"
# env:
# ACTIONS_STEP_DEBUG: ${{ secrets.ACTIONS_STEP_DEBUG }}
- name: Validate formatted version output
run: |
if [ -z "${{ needs.format.outputs.version }}" ]; then
echo "Error: formatted version output is empty."
exit 1
else
echo "Formatted version output: ${{ needs.format.outputs.version }}"
fi
- name: Get current date
id: date
run: echo "date=$(date -u +'%Y%m%d')" >> $GITHUB_ENV
- name: Get package filename
run: |
echo "filename=${{ env.debpackagename }}_${{ needs.format.outputs.version }}~gha${{ env.date }}+${{ matrix.arch }}_${{ matrix.distro }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Validate Environment Variables
run: |
if [ -z "${{ env.debpackagename }}" ]; then
echo "Error: debpackagename cannot be empty"
exit 1
fi
shell: bash
- name: sbuild deb pkg for ${{ matrix.distro }}+${{ matrix.arch }}
uses: wlan-pi/sbuild-debian-package@main
id: build-debian-package
with:
distro: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
- name: Archive artifacts and upload to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ env.filename }}
path: ${{ steps.build-debian-package.outputs.deb-package }}
name: sbuild pkg
needs:
- format
uses: WLAN-Pi/gh-workflows/.github/workflows/sbuild-pkg.yml@main
with:
pkg: wlanpi-core
version: ${{ needs.format.outputs.version }}
slack-workflow-status:
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }}
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }}
name: Post Workflow Status to Slack
needs:
- sbuild
Expand All @@ -70,4 +28,4 @@ jobs:
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
79 changes: 12 additions & 67 deletions .github/workflows/deploy-to-packagecloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
- main
paths:
- 'debian/changelog'
env:
debpackagename: wlanpi-core
jobs:
check_version:
name: Check py & deb pkg versions match
Expand All @@ -18,74 +16,21 @@ jobs:
format:
name: Get formatted version for filename
uses: WLAN-Pi/gh-workflows/.github/workflows/get-formatted-version-string.yml@main
sbuild:
name: sbuild ${{ matrix.distro }}+${{ matrix.arch }} pkg
runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}"
needs: [format, check_version]
strategy:
fail-fast: false
matrix:
distro: [bullseye,bookworm]
arch: [arm64]
environment: PACKAGECLOUD
steps:
- name: Validate formatted version output
run: |
if [ -z "${{ needs.format.outputs.version }}" ]; then
echo "Error: formatted version output is empty."
exit 1
else
echo "Formatted version output: ${{ needs.format.outputs.version }}"
fi
- name: Get current date
id: date
run: echo "date=$(date -u +'%Y%m%d')" >> $GITHUB_ENV
- name: Gset package filename
run: |
echo "filename=${{ env.debpackagename }}_${{ needs.format.outputs.version }}~gha${{ env.date }}+${{ matrix.arch }}_${{ matrix.distro }}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
- name: Validate Environment Variables
run: |
if [ -z "${{ env.debpackagename }}" ]; then
echo "Error: debpackagename cannot be empty"
exit 1
fi
shell: bash
- name: sbuild deb pkg for ${{ matrix.distro }}+${{ matrix.arch }}
uses: wlan-pi/sbuild-debian-package@main
id: build-debian-package
with:
distro: ${{ matrix.distro }}
arch: ${{ matrix.arch }}
- name: Archive artifacts and upload to GitHub
uses: actions/upload-artifact@v4
with:
name: ${{ env.filename }}
path: ${{ steps.build-debian-package.outputs.deb-package }}
- name: Upload armhf pkg to raspbian/${{ matrix.distro }}
if: ${{ matrix.arch == 'armhf' && (github.repository_owner == 'WLAN-Pi') }}
uses: danielmundi/upload-packagecloud@main
with:
package-name: ${{ steps.build-debian-package.outputs.deb-package }}
packagecloud-username: wlanpi
packagecloud-repo: dev
packagecloud-distrib: raspbian/${{ matrix.distro }}
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Upload arm64 pkg to debian/${{ matrix.distro }}
if: ${{ matrix.arch == 'arm64' && (github.repository_owner == 'WLAN-Pi') }}
uses: danielmundi/upload-packagecloud@main
with:
package-name: ${{ steps.build-debian-package.outputs.deb-package }}
packagecloud-username: wlanpi
packagecloud-repo: dev
packagecloud-distrib: debian/${{ matrix.distro }}
packagecloud-token: ${{ secrets.PACKAGECLOUD_TOKEN }}
sbuild_deploy:
name: sbuild deploy pkg
needs:
- format
- check_version
uses: WLAN-Pi/gh-workflows/.github/workflows/sbuild-deploy-pkg.yml@main
with:
pkg: wlanpi-core
version: ${{ needs.format.outputs.version }}
secrets: inherit
slack-workflow-status:
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }}
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }}
name: Post workflow status to Slack
needs:
- sbuild
- sbuild_deploy
runs-on: "${{ vars.RUNS_ON || 'ubuntu-22.04' }}"
steps:
- name: Slack Workflow Notification
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-style-police.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
tox -e formatcheck
slack-workflow-status:
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }}
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }}
name: Post Workflow Status to Slack
needs:
- python-style-police
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
tox
slack-workflow-status:
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (github.event.pull_request.head.repo.full_name == github.repository) }}
if: ${{ always() && (github.repository_owner == 'WLAN-Pi') && (! github.event.pull_request.head.repo.fork) }}
name: Post Workflow Status to Slack
needs:
- python
Expand Down

0 comments on commit 7f3ee96

Please sign in to comment.