Skip to content

Add resources links in operation forbidden modal #12975

Add resources links in operation forbidden modal

Add resources links in operation forbidden modal #12975

Workflow file for this run

name: Pull request environment
on:
pull_request:
types:
- opened
- synchronize
- labeled
jobs:
check-env-creation-privilege:
name: Check if the environment creation criteria are met, store in the job output
runs-on: ubuntu-24.04
if: vars.PR_ENV_ALLOW_LIST != '' && vars.PR_ENV_LABEL != ''
outputs:
create_env: ${{ steps.check.outputs.create_env }}
steps:
- id: check
run: echo "create_env=${{ contains(fromJson(vars.PR_ENV_ALLOW_LIST), github.event.sender.login) && contains(github.event.pull_request.labels.*.name, vars.PR_ENV_LABEL) }}" >> "$GITHUB_OUTPUT"
publish-containers:
name: Publish GHCR Containers
uses: trento-project/.github/.github/workflows/publish-containers.yaml@b3aa163d3e0872c07ccf3755928f21c070ca0e5b # v1.1.0
needs: check-env-creation-privilege
if: needs.check-env-creation-privilege.outputs.create_env == 'true'
with:
image_name: trento-web
tag: ${{ github.event.pull_request.number }}-env
branch: ${{ github.head_ref }}
extra_build_args: |
MIX_ENV=prod
GTM_ID=${{ vars.GTM_ID }}
secrets:
gh_token: ${{ secrets.TRENTOBOT_GH_PAT }}
ssh_key: ${{ secrets.TRENTOBOT_SSH_KEY }}
create-pr-environment:
name: Create or update the pr environment
runs-on: ubuntu-24.04
needs: publish-containers
env:
PR_BASE_URL: ${{ github.event.pull_request.number }}.prenv.trento.suse.com
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Checkout ansible repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
repository: trento-project/ansible
path: ansible
- name: Install ansible-core
run: sudo pipx install --force ansible-core==2.16.3
- name: Install galaxy deps
run: ansible-galaxy install -r ansible/requirements.yml
- name: Run playbook
uses: dawidd6/action-ansible-playbook@126642a1c6ce512da255ef2b41e8ee90f0077474 # v9
with:
playbook: ansible/playbook.yml
key: ${{ secrets.SSH_PR_MACHINE_KEY }}
inventory: |
all:
vars:
ansible_user: ec2-user
ansible_python_interpreter: /usr/bin/python3
trento_server_name: '${{ env.PR_BASE_URL }}'
trento_web_admin_password: 'adminpassword'
trento_web_postgres_username: '${{ env.PR_NUMBER }}web'
trento_web_postgres_password: 'trento'
trento_web_postgres_db: '${{ env.PR_NUMBER }}db'
trento_web_postgres_event_store: '${{ env.PR_NUMBER }}edb'
web_prometheus_url: 'http://localhost'
trento_wanda_postgres_username: '${{ env.PR_NUMBER }}wanda'
trento_wanda_postgres_password: 'wanda'
trento_wanda_postgres_db: '${{ env.PR_NUMBER }}wandadb'
trento_rabbitmq_username: '${{ env.PR_NUMBER }}rabbitusr'
trento_rabbitmq_password: 'trento'
trento_rabbitmq_vhost: '${{ env.PR_NUMBER }}'
rproxy_web_upstream_name: '${{ env.PR_NUMBER }}web'
rproxy_wanda_upstream_name: '${{ env.PR_NUMBER }}wanda'
rproxy_prometheus_upstream_name: '${{ env.PR_NUMBER }}prometheus'
rproxy_vhost_filename: '${{ env.PR_NUMBER }}'
rproxy_ssl_cert: '${{ secrets.PR_ENV_SSL_CERT }}'
rproxy_ssl_key: '${{ secrets.PR_ENV_SSL_CERT_KEY }}'
rproxy_ssl_cert_as_base64: true
rproxy_ssl_key_as_base64: true
trento_server_url: 'http://${{ env.PR_BASE_URL }}'
trento_prometheus_auth: 'none'
children:
trento_server:
hosts:
server:
ansible_host: ${{ secrets.PR_ENV_MACHINE_IP }}
postgres_hosts:
hosts:
server:
ansible_host: ${{ secrets.PR_ENV_MACHINE_IP }}
rabbitmq_hosts:
hosts:
server:
ansible_host: ${{ secrets.PR_ENV_MACHINE_IP }}
prometheus_hosts:
hosts:
server:
ansible_host: ${{ secrets.PR_ENV_MACHINE_IP }}
options: |
--extra-vars "trento_install_method='docker' \
trento_docker_network_name='${{ env.PR_NUMBER }}net' \
trento_force_pull_images='true' \
trento_web_container_name='${{ env.PR_NUMBER }}web' \
web_container_image='ghcr.io/trento-project/trento-web:${{ env.PR_NUMBER }}-env' \
web_force_recreate_container='true' \
web_enable_api_key='false' \
wanda_container_image='ghcr.io/trento-project/trento-wanda:demo' \
wanda_container_name='${{ env.PR_NUMBER }}wanda' \
wanda_force_recreate_wanda_container='true' \
wanda_checks_container_name='${{ env.PR_NUMBER }}checks' \
wanda_force_recreate_checks_container='true'"
run-photofinish-demo-env:
name: Use photofinish to push mock data to the pr environment
runs-on: ubuntu-24.04
needs: create-pr-environment
env:
TRENTO_PR_ENV_URL: "${{ github.event.pull_request.number }}.prenv.trento.suse.com"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Install photofinish
uses: jaxxstorm/action-install-gh-release@25e24d2d23ae098373794ef1d6faecb48ee52da8 # v3.0.0
with:
repo: trento-project/photofinish
tag: v1.4.2
cache: enable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Give executable permissions to photofinish
run: chmod +x $(whereis photofinish | cut -d" " -f2)
- name: Push data
run: |
photofinish run demo -u "https://$TRENTO_PR_ENV_URL/api/v1/collect"
comment-pr:
name: Comment on the PR with the environment URL
runs-on: ubuntu-24.04
needs: run-photofinish-demo-env
steps:
- name: Checkout source
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Comment on the PR
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
env:
FQDN: prenv.trento.suse.com
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { onPrEnvCreated } = require('.github/scripts/pr_env.js')(github, context);
onPrEnvCreated(process.env.FQDN).catch(console.error);