chore: update analytics-provider-segment wrapper #1172
Workflow file for this run
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
# Copyright 2023 The Janus IDP Authors | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: PR Build Image | |
on: | |
pull_request_target: | |
paths-ignore: | |
- 'docs/**' | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.number || github.event.pull_request.head.ref }} | |
cancel-in-progress: true | |
env: | |
REGISTRY: quay.io | |
jobs: | |
build-image: | |
name: Build Image | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
- name: Get the latest commits from base branch | |
run: | | |
git remote add base-origin https://github.com/janus-idp/backstage-showcase || true | |
git config user.name "${{ github.event.pull_request.user.login }}" | |
git config user.email "${{ github.event.pull_request.user.email }}" | |
echo "Updating PR with latest commits from ${{ github.event.pull_request.base.ref }} ..." | |
git fetch base-origin ${{ github.event.pull_request.base.ref }} | |
git merge --no-edit base-origin/${{ github.event.pull_request.base.ref }} | |
- name: Get the last commit short SHA of the PR | |
run: | | |
SHORT_SHA=$(git rev-parse --short=8 ${{ github.event.pull_request.head.sha }}) | |
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV | |
if [[ -f packages/app/src/build-metadata.json ]]; then | |
repoPR="${{ github.repository }}/pull/${{ github.event.number }}" | |
now="$(date -u +%FT%TZ)" | |
sed -i packages/app/src/build-metadata.json -r \ | |
-e 's|("Last Commit:.+)|"Last Commit: '$repoPR' @ '$SHORT_SHA'"|' | |
fi | |
- name: Build and Push with Buildx | |
uses: ./.github/actions/docker-build | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ vars.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_TOKEN }} | |
imageName: ${{ github.repository }} | |
imageTags: | | |
type=ref,prefix=pr-,event=pr | |
type=ref,prefix=pr-,suffix=-${{ env.SHORT_SHA }},event=pr | |
# to autodelete PR image tags, set an expiry date | |
imageLabels: quay.expires-after=14d | |
push: true | |
- name: Comment the image pull link | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'The image is available at:\n* [`quay.io/${{ github.repository }}:pr-${{ github.event.number }}`](https://quay.io/${{ github.repository }}:pr-${{ github.event.number }}) or\n* [`quay.io/${{ github.repository }}:pr-${{ github.event.number }}-${{ env.SHORT_SHA }}`](https://quay.io/${{ github.repository }}:pr-${{ github.event.number }}-${{ env.SHORT_SHA }})' | |
}) |