Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GHA stuff #563

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 5 additions & 32 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ on:
types:
- opened
- synchronize
- closed

concurrency:
group: docs

permissions:
contents: write
pull-requests: write

jobs:
build-and-preview:
if: github.event.action == 'opened' || github.event.action == 'synchronize'
Expand Down Expand Up @@ -70,41 +73,11 @@ jobs:
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}

comment-preview-url:
needs: build-and-preview
if: needs.build-and-preview.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Comment Preview URL
- name: Comment preview URL
uses: thollander/actions-comment-pull-request@v2
with:
message: |
<!-- preview-url-comment -->
Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }}
Please avoid using the search feature and navigation bar in PR previews!
comment_tag: preview-url-comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR Preview Directory
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git pull origin gh-pages
rm -rf ${PREVIEW_DIR}
git add .
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/remove_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Remove PR previews

on:
pull_request_target:
types:
- closed

permissions:
contents: write

jobs:
delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR Preview Directory
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git pull origin gh-pages
rm -rf ${PREVIEW_DIR}
git add .
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
git push
7 changes: 6 additions & 1 deletion .github/workflows/version_check.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ if ENV["TARGET_IS_MASTER"] == "true"
println("$(MANIFEST_TOML_PATH) is out of date; updating")
old_env = Pkg.project().path
Pkg.activate(".")
Pkg.update()
try
Pkg.add(name="Turing", version=latest_version)
catch e
# If the Manifest couldn't be updated, the error will be shown later
println(e)
end
# Check if versions match now, error if not
Pkg.activate(old_env)
manifest_toml = TOML.parsefile(MANIFEST_TOML_PATH)
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/version_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ jobs:

- name: Check version consistency
id: version_check
continue-on-error: true
run: julia --color=yes .github/workflows/version_check.jl

- name: Create a PR with suggested changes
id: create_pr
if: steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK)
if: always() && steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK)
uses: peter-evans/create-pull-request@v6
with:
base: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
Expand All @@ -66,7 +65,7 @@ jobs:
title: "Update Turing.jl version to match latest release"

- name: Comment on PR about suggested changes (if PR was made)
if: github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created'
if: always() && github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Expand Down
Loading