Skip to content

Commit

Permalink
forks now detected in the premerge workflow. tested locally on upstre…
Browse files Browse the repository at this point in the history
…am and fork using act.
  • Loading branch information
fuma419 committed Apr 21, 2024
1 parent 9f8894b commit 82dfc8a
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/premerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
distro: [rockylinux, ubuntu]
env:
REGISTRY: ghcr.io
BRANCH: ${{ github.event.inputs.branch || '' }}
BRANCH: ${{ github.event.inputs.branch || github.head_ref }}
if: github.event.pull_request.draft == false
steps:
- name: Maximize build space
Expand All @@ -47,24 +47,31 @@ jobs:
- uses: actions/checkout@v3
- name: Define BRANCH, COMMIT and G_ACCOUNT in environment
run: |
if [[ "${{ github.event.pull_request.head.repo.fork }}" == "true" ]]; then
# This means the PR is from a fork
echo "G_ACCOUNT=${{ github.event.pull_request.head.repo.owner.login }}" >> $GITHUB_ENV
echo "IS_FORK=${{ github.event.pull_request.head.repo.fork }}" >> $GITHUB_ENV
echo "FORK_OWNER=${{ github.event.pull_request.head.repo.owner.login }}" >> $GITHUB_ENV
echo "REPO_OWNER=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "COMMIT_SHA=$(git rev-parse --short ${{ github.sha }})" >> $GITHUB_ENV
- name: Setup G_ACCOUNT based on fork status
run: |
if [ "$IS_FORK" = "true" ]; then
echo "This means the PR is from a fork"
G_ACCOUNT="$FORK_OWNER"
else
# This means the PR is from the same repository
echo "G_ACCOUNT=${{ github.repository_owner }}" >> $GITHUB_ENV
echo "This means the PR is from the same repository"
G_ACCOUNT="$REPO_OWNER"
fi
echo "BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV
echo "COMMIT=$(git rev-parse --short "${{ github.sha }}")" >> $GITHUB_ENV
echo "G_ACCOUNT=$G_ACCOUNT" >> $GITHUB_ENV
- name: Testing guild-deploy.sh (IO fork of libsodium)
run: |
docker build . \
--file files/tests/pre-merge/${{ matrix.distro }}-guild-deploy.sh-l.containerfile \
--compress \
--build-arg BRANCH=${{ env.BRANCH }} \
--build-arg COMMIT=${{ env.COMMIT }} \
--build-arg G_ACCOUNT=${{ env.G_ACCOUNT }} \
--tag ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT }}
--build-arg BRANCH=$BRANCH \
--build-arg COMMIT=$COMMIT_SHA \
--build-arg G_ACCOUNT=$G_ACCOUNT \
--tag $REGISTRY/$G_ACCOUNT/pre-merge-${{ matrix.distro }}:guild-deploy-l_$COMMIT_SHA
- name: Get Image ID
run: |
PREMERGE_IMAGE_ID1=$(docker inspect ${{ env.REGISTRY }}/${{ env.G_ACCOUNT }}/pre-merge-${{ matrix.distro }}:guild-deploy-l_${{ env.COMMIT }} --format='{{.Id}}')
Expand Down

0 comments on commit 82dfc8a

Please sign in to comment.