Auto Update #4466
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto Update | |
on: | |
schedule: | |
- cron: '0 0 * * FRI' | |
workflow_dispatch: | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Install hub | |
run: sudo apt-get install -y hub | |
- uses: cachix/install-nix-action@V27 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- uses: cachix/cachix-action@v15 | |
with: | |
name: vulkan-haskell | |
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' | |
- name: Init git | |
run: | | |
git config user.name 'Three Of Twelve' | |
git config user.email '[email protected]' | |
- id: init | |
run: | | |
message="> $(curl https://home.monoid.al/quote/tuvok --fail || echo "No response. He's deactivated his communication system.")" | |
message="${message//'%'/'%25'}" | |
message="${message//$'\n'/'%0A'}" | |
message="${message//$'\r'/'%0D'}" | |
issue_body=~/issue_body | |
echo "::set-output name=issue_body::$issue_body" | |
echo "$message" > "$issue_body" | |
echo >> "$issue_body" | |
pr_body=~/pr_body | |
echo "::set-output name=pr_body::$pr_body" | |
echo "$message" > "$pr_body" | |
echo >> "$pr_body" | |
- name: Build dependencies | |
run: | | |
nix-build -A generate-new | |
nix-build '<nixpkgs>' -A python3 -A python3Packages.pyparsing -A asciidoctor -A gnumake -A nodejs -A nodePackages.he -A nodePackages.escape-string-regexp | |
nix-build '<nixpkgs>' -A haskellPackages.hpack | |
nix-build '<nixpkgs>' -A doxygen | |
- name: run update.sh | |
id: update | |
env: | |
issue_body: ${{ steps.init.outputs.issue_body }} | |
pr_body: ${{ steps.init.outputs.pr_body }} | |
tok: ${{ secrets.TUVOK_TOKEN }} | |
run: | | |
ndd="$HOME/no-doc-diff.patch" | |
set +e | |
./scripts/update.sh --no-doc-diff "$ndd" 2>&1 | tee --append ~/update_output | |
code=${PIPESTATUS[0]} | |
set -e | |
{ | |
echo '<details> <summary>log of `generate-new/bin/vk`</summary> <p>' | |
echo '' | |
echo '```' | |
cat ~/update_output | |
echo '```' | |
echo '' | |
echo '</p></details>' | |
} >> "$issue_body" | |
gist="$HOME/gist-post.json" | |
make_gist(){ | |
set -o pipefail | |
jq -R -s '{"description": "Vulkan update diff", "public": false, "files": {"vulkan.diff": {"content": .}}}' < "$ndd" > "$gist" && | |
curl \ | |
--header "Content-Type: application/json" \ | |
--data @"$gist" \ | |
--user "$tok:" \ | |
https://api.github.com/gists | | |
jq --raw-output .html_url | | |
sed 's/.*/[Diff without documentation changes](\0)/' | |
} | |
gist_url=$(make_gist || echo "Failed to create gist for diff") | |
echo gist_url = "$gist_url" | |
{ | |
echo "pr_message<<EOF_HS_VK" | |
cat "$pr_body" | |
echo | |
echo "$gist_url" | |
echo "EOF_HS_VK" | |
} >> "$GITHUB_ENV" | |
(exit "$code") | |
- id: check_pr | |
run: | | |
echo "::set-output name=create_pr::true" | |
hub pr list --state open --head ThreeOfTwelve:vulkan-update-${{ steps.update.outputs.vulkan_version }} --format $'%U\n' | while read u; do | |
echo "PR already exists: $u" | |
echo "::set-output name=create_pr::false" | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.TUVOK_TOKEN }} | |
- name: Create Pull Request | |
uses: peter-evans/[email protected] | |
if: steps.check_pr.outputs.create_pr == 'true' | |
with: | |
token: ${{ secrets.TUVOK_TOKEN }} | |
push-to-fork: ThreeOfTwelve/vulkan | |
delete-branch: true | |
branch: vulkan-update-${{ steps.update.outputs.vulkan_version }} | |
title: Update Vulkan to ${{ steps.update.outputs.vulkan_version }} | |
body: ${{ env.pr_message }} | |
- id: check_issue | |
if: ${{ failure() }} | |
run: | | |
echo "::set-output name=create_issue::true" | |
hub issue --state open --format $'%U %t\n' | grep -i 'Failed to regenerate source for Vulkan ${{ steps.update.outputs.vulkan_version }}' | while read u; do | |
echo "Issue already exists: $u" | |
echo "::set-output name=create_issue::false" | |
done | |
env: | |
GITHUB_TOKEN: ${{ secrets.TUVOK_TOKEN }} | |
- name: Create issue for failure | |
if: ${{ failure() && steps.check_issue.outputs.create_issue == 'true' }} | |
uses: peter-evans/create-issue-from-file@v5 | |
with: | |
title: Failed to regenerate source for Vulkan ${{ steps.update.outputs.vulkan_version }} | |
content-filepath: ${{ steps.init.outputs.issue_body }} | |
token: ${{ secrets.TUVOK_TOKEN }} |