-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…n pr * add gitinfo page, use env variables in gh branch wf * add workflow to check files changed in pr
- Loading branch information
Showing
13 changed files
with
334 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Context testing | ||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
dump_contexts_to_log: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJson(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
- name: pr title | ||
env: | ||
TITLE: ${{ github.event.pull_request.title }} | ||
P_ID: "${TITLE:0:2}" | ||
|
||
run: | | ||
echo P_ID: "$P_ID" | ||
echo "Title: $TITLE" | ||
PID="${TITLE:0:2}" | ||
echo "new pid $PID" | ||
which tr | ||
PID2=$(echo $PID | tr '[:upper:]' '[:lower:]') | ||
echo "new pid2 $PID2" | ||
# - name: Dump job context | ||
# env: | ||
# JOB_CONTEXT: ${{ toJson(job) }} | ||
# run: echo "$JOB_CONTEXT" | ||
# - name: Dump steps context | ||
# env: | ||
# STEPS_CONTEXT: ${{ toJson(steps) }} | ||
# run: echo "$STEPS_CONTEXT" | ||
# - name: Dump runner context | ||
# env: | ||
# RUNNER_CONTEXT: ${{ toJson(runner) }} | ||
# run: echo "$RUNNER_CONTEXT" | ||
# - name: Dump strategy context | ||
# env: | ||
# STRATEGY_CONTEXT: ${{ toJson(strategy) }} | ||
# run: echo "$STRATEGY_CONTEXT" | ||
# - name: Dump matrix context | ||
# env: | ||
# MATRIX_CONTEXT: ${{ toJson(matrix) }} | ||
# run: echo "$MATRIX_CONTEXT" | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: check only own files have been changed | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
check-own-folder: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: vars | ||
run: | | ||
echo "some github variables:" \ | ||
echo $GITHUB_REF \ | ||
echo "sha: ${{ github.event.head_commit.sha }}" \ | ||
echo "message: ${{ github.event.head_commit.message }}" \ | ||
echo "pr commit sha: ${{ github.event.pull_request.head.sha }}" \ | ||
echo "pr commit ref: ${{ github.event.pull_request.head.ref }}" \ | ||
echo "pr commit message: ${{ github.event.pull_request.head.message }}" \ | ||
echo "pr commit: ${{ github.event.pull_request.head }}" \ | ||
echo "base ref: ${{ github.event.pull_request.base.ref }}" \ | ||
echo "base sha: ${{ github.event.pull_request.base.sha }}" | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
submodules: false | ||
|
||
- name: "diff commit" | ||
run: | | ||
git status | ||
echo "files changed: " | ||
git diff --name-only ${{ github.event.head_commit.sha }} | ||
continue-on-error: true | ||
|
||
- name: "diff pr" | ||
continue-on-error: true | ||
run: | | ||
echo "files changed: " | ||
git diff --name-only ${{ github.event.pull_request.head.sha }} | ||
- name: "diff base head" | ||
continue-on-error: true | ||
run: | | ||
echo "files changed: " | ||
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | ||
- name: "git base head grep" | ||
continue-on-error: true | ||
run: | | ||
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -v ss24 | ||
- name: "git diff main with check" | ||
continue-on-error: true | ||
run: | | ||
if [[ "" != $(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -v ss24) ]]; then | ||
echo "more files changed than allowed:" | ||
git diff --name-only main | grep -v ss24 | ||
else | ||
echo "all good" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: test checkout action | ||
on: | ||
# push: | ||
# branches: | ||
# - gh_pages_deploy_fix # Set a branch that will trigger a deployment | ||
workflow_dispatch: | ||
|
||
jobs: | ||
checkout-only: | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: false | ||
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod | ||
|
||
- name: Get Theme | ||
run: | | ||
git submodule update --init themes/showtime-theme-2021 | ||
- name: Echo something | ||
run: echo "Output after checkout - should work" | ||
|
||
job-after-checkout: | ||
runs-on: ubuntu-latest | ||
needs: checkout-only | ||
steps: | ||
- name: Echo something | ||
run: echo "Output from after-checkout job" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generic Workflow that builds the hugo page from . (root dir of the repo) | ||
# sets the baseURL for hugo to 'https://<owner>.github.io/<repo>' | ||
# publishes the hugo page using the (older) option by pushing the | ||
# page to the branch gh-pages | ||
|
||
# use it with <repo>->Settings->Pages "Deploy from a branch" | ||
# Select Branch: "gh-pages" Select Folder: "/(root)" | ||
# Contains a RUN_IF to prevent it from running in the original repo | ||
|
||
# This is here for legacy reasons. If in doubt, use the workflow in gh-pages-action.yml ! | ||
|
||
name: Deploy Page using Branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- gh_pages_deploy_fix # Set a branch that will trigger a deployment | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
deploy: | ||
if: ${{ github.repository_owner != 'htw-imi-showtime' }} | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: false | ||
fetch-depth: 1 # Fetch all history for .GitInfo and .Lastmod | ||
|
||
- name: Get Theme | ||
run: | | ||
git submodule update --init themes/showtime-theme-2021 | ||
# see https://github.com/marketplace/actions/hugo-setup | ||
- name: Setup Hugo | ||
uses: peaceiris/actions-hugo@v3 | ||
with: | ||
hugo-version: 'latest' | ||
extended: true | ||
|
||
- name: Build | ||
run: | | ||
hugo \ | ||
--environment production \ | ||
--buildDrafts \ | ||
--baseURL 'https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}' | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v4 | ||
if: github.ref == 'refs/heads/main' | ||
with: | ||
publish_dir: ./public |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Own Files Only | ||
|
||
# this workflow checks whether a pull request changes only files in the project folder" | ||
# PR Titles have to start with the Project ID! (e.g. B1: ....) | ||
on: | ||
pull_request: | ||
|
||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
check-own-files: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: vars | ||
run: | | ||
echo "some github variables:" \ | ||
echo $GITHUB_REF \ | ||
echo "sha: ${{ github.event.head_commit.sha }}" \ | ||
echo "message: ${{ github.event.head_commit.message }}" \ | ||
echo "pr commit sha: ${{ github.event.pull_request.head.sha }}" \ | ||
echo "pr commit ref: ${{ github.event.pull_request.head.ref }}" \ | ||
echo "pr commit message: ${{ github.event.pull_request.head.message }}" \ | ||
echo "pr commit: ${{ github.event.pull_request.head }}" \ | ||
echo "base ref: ${{ github.event.pull_request.base.ref }}" \ | ||
echo "base sha: ${{ github.event.pull_request.base.sha }}" \ | ||
echo "event: ${{ github.event }}" \ | ||
echo "event: ${{ github.event.message }}" \ | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: false | ||
|
||
- name: "checkout relevant refs" | ||
run: | | ||
git log | ||
git status | ||
git fetch --no-tags --depth=1 origin main | ||
git checkout main | ||
echo "about to pr base" | ||
git fetch origin ${{ github.event.pull_request.base.sha }} | ||
git checkout -b pr_base ${{ github.event.pull_request.base.sha }} | ||
# echo "about to checkout merge commit" | ||
# git fetch origin ${{ github.event.pull_request.merge_commit_sha }} | ||
# git checkout -b pr_merge_commit ${{ github.event.pull_request.merge_commit_sha }} | ||
echo "about to checkout head" | ||
git fetch origin ${{ github.event.pull_request.head.sha }} | ||
git checkout -b pr_head ${{ github.event.pull_request.head.sha }} | ||
- name: extract project id | ||
id: extract_pid | ||
env: | ||
PR_TITLE: ${{ github.event.pull_request.title }} | ||
|
||
run: | | ||
echo P_ID: "$P_ID" | ||
echo "PR_TITLE: $PR_TITLE" | ||
PID="${PR_TITLE:0:2}" | ||
echo "PID $PID" | ||
PID2=$(echo $PID | tr '[:upper:]' '[:lower:]') | ||
echo "PID2 $PID2" | ||
echo "project_id=$PID2" >> $GITHUB_OUTPUT | ||
echo "allowed_path=ss24/$PID2" >> $GITHUB_OUTPUT | ||
- name: "diff base head" | ||
continue-on-error: true | ||
run: | | ||
echo "files changed: " | ||
git diff --name-only pr_base pr_head | ||
- name: "grep test" | ||
continue-on-error: true | ||
run: | | ||
echo "files changed: " | ||
git diff --name-only pr_base pr_head | grep -v ${{ steps.extract_pid.outputs.allowed_path }} | ||
- name: "git diff main with check" | ||
run: | | ||
if [[ "" != $(git diff --name-only pr_base pr_head | grep -v ${{ steps.extract_pid.outputs.allowed_path }}) ]]; then | ||
echo "ERROR: More files changed than allowed!" | ||
echo "------ Additional Files: " | ||
git diff --name-only pr_base pr_head | grep -v "${{ steps.extract_pid.outputs.allowed_path }}" | ||
echo "------ Allowed Files:" | ||
git diff --name-only pr_base pr_head | grep "${{ steps.extract_pid.outputs.allowed_path }}" | ||
exit 123 | ||
else | ||
echo "all good" | ||
fi |
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
Oops, something went wrong.