diff --git a/.github/workflows/premerge.yml b/.github/workflows/premerge.yml index 38f74c792..d9e359487 100644 --- a/.github/workflows/premerge.yml +++ b/.github/workflows/premerge.yml @@ -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 @@ -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}}')