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 098a328
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 7 deletions.
54 changes: 50 additions & 4 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 @@ -71,7 +72,7 @@ jobs:
# extract first line and cut out the "/build-image" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
echo "arguments are: $ARGS"
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* ]] ; then
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* || "$ARGS" == *"--updates.img"* ]] ; then
ARGS="$ARGS --boot.iso"
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi
Expand Down Expand Up @@ -292,9 +293,51 @@ 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
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: Install required packages
run: |
sudo apt install -y dracut
- name: Create updates image
run: |
./scripts/makeupdates
new_name="${{ needs.pr-info.outputs.image_description }}-updates.img"
mv updates.img "$new_name"
lsinitrd "$new_name"
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: updates.img for ${{ needs.pr-info.outputs.image_description }}
path: |
*.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 +366,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
52 changes: 49 additions & 3 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 @@ -65,7 +66,7 @@ jobs:
# extract first line and cut out the "/build-image" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
echo "arguments are: $ARGS"
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* ]] ; then
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* || "$ARGS" == *"--updates.img"* ]] ; then
ARGS="$ARGS --boot.iso"
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi
Expand Down Expand Up @@ -286,9 +287,51 @@ 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
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: Install required packages
run: |
sudo apt install -y dracut

- name: Create updates image
run: |
./scripts/makeupdates
new_name="${{ needs.pr-info.outputs.image_description }}-updates.img"
mv updates.img "$new_name"
lsinitrd "$new_name"

- name: Upload image
uses: actions/upload-artifact@v3
with:
name: updates.img for ${{ needs.pr-info.outputs.image_description }}
path: |
*.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 +360,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 098a328

Please sign in to comment.