diff --git a/.github/workflows/gcp-rpm-build-and-test.yml b/.github/workflows/gcp-rpm-build-and-test.yml index fd0b810..15ed781 100644 --- a/.github/workflows/gcp-rpm-build-and-test.yml +++ b/.github/workflows/gcp-rpm-build-and-test.yml @@ -54,19 +54,33 @@ jobs: # instead we assume success at the beginning and then let any axis that fails remove the # lastSuccessfulBuild link if it fails name: Create lastBuild and lastSuccessfulBuild symlinks + permissions: + statuses: write + contents: read + id-token: write runs-on: [self-hosted, gcp] steps: + # we are required to checkout the code to have auth save the token we need for GCSFUSE + # per https://github.com/google-github-actions/auth#inputs-miscellaneous + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Authenticate to GCP id: gcp-authentication uses: 'google-github-actions/auth@v2' with: project_id: ${{ env.PROJECT_ID }} workload_identity_provider: ${{ env.WIP_PROVIDER }} + create_credentials_file: true + token_format: access_token + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v2" - name: Set up GCSFUSE run: | - fusermount -u ${GCS_BUCKET_MOUNT_PT} || true + sudo fusermount -u ${GCS_BUCKET_MOUNT_PT} && sudo rm -fr /tmp/gcp_artifacts || true mkdir -p "${GCS_BUCKET_MOUNT_PT}" - gcsfuse --implicit-dirs "${GCS_BUCKET}" "${GCS_BUCKET_MOUNT_PT}" + sudo -u ext_mlawsonca_google_com gcsfuse --implicit-dirs "${GCS_BUCKET}" "${GCS_BUCKET_MOUNT_PT}" - name: Create lastBuild and lastSuccessfulBuild symlinks run: mkdir -p ${REPO_PATH}; rm -f ${REPO_PATH}last{,Successful}Build; @@ -104,6 +118,8 @@ jobs: name: Build RPM permissions: statuses: write + contents: read + id-token: write runs-on: [self-hosted, gcp] needs: [Create-symlinks, Calc-rpm-build-matrix] if: needs.Create-symlinks.result == 'success' && @@ -233,11 +249,15 @@ jobs: with: project_id: ${{ env.PROJECT_ID }} workload_identity_provider: ${{ env.WIP_PROVIDER }} + create_credentials_file: true + token_format: access_token + - name: "Set up Cloud SDK" + uses: "google-github-actions/setup-gcloud@v2" - name: Set up GCSFUSE run: | - fusermount -u ${GCS_BUCKET_MOUNT_PT} || true + sudo fusermount -u ${GCS_BUCKET_MOUNT_PT} && sudo rm -fr /tmp/gcp_artifacts || true mkdir -p "${GCS_BUCKET_MOUNT_PT}" - gcsfuse --implicit-dirs "${GCS_BUCKET}" "${GCS_BUCKET_MOUNT_PT}" + sudo -u ext_mlawsonca_google_com gcsfuse --implicit-dirs "${GCS_BUCKET}" "${GCS_BUCKET_MOUNT_PT}" - name: Remove lastSuccessfulBuild link and exit failure if: steps.test-repo.outcome != 'success' run: rm -f ${REPO_PATH}lastSuccessfulBuild;