Skip to content

Commit

Permalink
infra: Build also updates.img by comment
Browse files Browse the repository at this point in the history
To do so: /build-image --updates.img
  • Loading branch information
VladimirSlavik committed Aug 24, 2023
1 parent 678e3c9 commit 6f867c0
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 5 deletions.
47 changes: 44 additions & 3 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: build-iso.yml.j2
# The template is located in: build-image.yml.j2

# Build a bootable image from a PR triggered by a "/build-image" comment or manually.
#
# Choose type of the image with these options:
# --boot.iso
# --live
# --updates.img
#
# If none of these is present, --boot-iso is assumed.
# If both are present, both variants are built.
# If more are present at once, all variants are built.
#
# To use webui on boot.iso, add also:
# --webui
Expand Down Expand Up @@ -292,9 +293,46 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

updates-img:
needs: pr-info
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--updates.img')
runs-on: ubuntu-latest
steps:
timeout-minutes: 10
env:
STATUS_NAME: updates-img
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 0

- name: Create updates image
run: |
./scripts/makeupdates
lsinitrd updates.img
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: updates.img for ${{ needs.pr-info.outputs.image_description }}
path: |
updates.img
- name: Set result status
if: always()
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: ${{ job.status }}
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

finalize:
needs: [pr-info, boot-iso, live-cd]
needs: [pr-info, boot-iso, live-cd, updates-img]
runs-on: ubuntu-latest
# needs always() to run even if builds failed
if: ${{ always() && !cancelled() && github.event_name != 'workflow_dispatch' && needs.pr-info.outputs.allowed_user == 'true' }}
Expand Down Expand Up @@ -323,6 +361,9 @@ jobs:
if [[ "${{ needs.pr-info.outputs.args }}" == *"--live"* ]] ; then
echo -e "- Live: ${{ needs.live-cd.result }}\n" >> comment.txt
fi
if [[ "${{ needs.pr-info.outputs.args }}" == *"--updates.img"* ]] ; then
echo -e "- \'updates.img\': ${{ needs.updates-img.result }}\n" >> comment.txt
fi
echo -e "\nDownload the images from the bottom of the [job status page]($url).\n" >> comment.txt
echo "Comment to be posted:"
Expand Down
45 changes: 43 additions & 2 deletions .github/workflows/build-image.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
# Choose type of the image with these options:
# --boot.iso
# --live
# --updates.img
#
# If none of these is present, --boot-iso is assumed.
# If both are present, both variants are built.
# If more are present at once, all variants are built.
#
# To use webui on boot.iso, add also:
# --webui
Expand Down Expand Up @@ -286,9 +287,46 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

updates-img:
needs: pr-info
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--updates.img')
runs-on: ubuntu-latest
steps:
timeout-minutes: 10
env:
STATUS_NAME: updates-img
steps:
- name: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 0

- name: Create updates image
run: |
./scripts/makeupdates
lsinitrd updates.img

- name: Upload image
uses: actions/upload-artifact@v3
with:
name: updates.img for ${{ needs.pr-info.outputs.image_description }}
path: |
updates.img

- name: Set result status
if: always()
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: ${{ job.status }}
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

finalize:
needs: [pr-info, boot-iso, live-cd]
needs: [pr-info, boot-iso, live-cd, updates-img]
runs-on: ubuntu-latest
# needs always() to run even if builds failed
if: ${{ always() && !cancelled() && github.event_name != 'workflow_dispatch' && needs.pr-info.outputs.allowed_user == 'true' }}
Expand Down Expand Up @@ -317,6 +355,9 @@ jobs:
if [[ "${{ needs.pr-info.outputs.args }}" == *"--live"* ]] ; then
echo -e "- Live: ${{ needs.live-cd.result }}\n" >> comment.txt
fi
if [[ "${{ needs.pr-info.outputs.args }}" == *"--updates.img"* ]] ; then
echo -e "- \'updates.img\': ${{ needs.updates-img.result }}\n" >> comment.txt
fi
echo -e "\nDownload the images from the bottom of the [job status page]($url).\n" >> comment.txt

echo "Comment to be posted:"
Expand Down

0 comments on commit 6f867c0

Please sign in to comment.