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

chore(ci): use temporary branch in PR events and turn off push trigge… #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
17 changes: 16 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Tests
on:
pull_request:
push:
branches:
- master

env:
KONG_VERSION: master
Expand All @@ -16,6 +18,8 @@ jobs:
build:
name: Build dependencies
runs-on: ubuntu-22.04
permissions:
contents: write # required to create branch

steps:
- name: Checkout source code
Expand All @@ -34,7 +38,7 @@ jobs:
branch=""

if [ ${{ github.event_name }} == 'pull_request' ]; then
branch=${GITHUB_HEAD_REF}
branch=${GITHUB_HEAD_REF}-merge
else
branch=${GITHUB_REF}
fi
Expand All @@ -51,6 +55,12 @@ jobs:
${{ env.BUILD_ROOT }}
key: ${{ hashFiles('src/**', 'lualib/**', '.github/workflows/tests.yml', 'kong/.requirements') }}

- name: Push PR merge to a temporary branch
# Push the temporary commit to a branch so that we can reference in build kong
if: github.event_name == 'pull_request' && steps.cache-deps.outputs.cache-hit != 'true'
run: |
git push https://oauth2:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/${{ github.head_ref }}-merge

- name: Install packages
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
Expand All @@ -72,6 +82,11 @@ jobs:
ldd $(which nginx)
luarocks

- name: Delete temporary branch
if: always() && github.event_name == 'pull_request' && steps.cache-deps.outputs.cache-hit != 'true'
run: |
git push https://oauth2:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git --delete refs/heads/${{ github.head_ref }}-merge

test:
name: Test
runs-on: ubuntu-22.04
Expand Down
Loading