Skip to content

Commit d775879

Browse files
Merge pull request #982 from jiridanek/jd_merge_in_rhds_rstudio___
NO-JIRA: chore(workbenches): bring in the rhel9 rstudio workbench and docs release notes for easier maintenance in single repository
2 parents 2c18a50 + b2862ff commit d775879

File tree

79 files changed

+4649
-24
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4649
-24
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ci/secrets/** filter=git-crypt diff=git-crypt

.github/workflows/build-notebooks-TEMPLATE.yaml

+38-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ name: Build & Publish Notebook Servers (TEMPLATE)
1515
required: true
1616
description: "top workflow's `github`"
1717
type: string
18+
subscription:
19+
required: false
20+
default: false
21+
description: "add RHEL subscription from github secret"
22+
type: boolean
1823

1924
jobs:
2025
build:
@@ -46,9 +51,40 @@ jobs:
4651
echo "CACHE=${CACHE,,}" >>${GITHUB_ENV}
4752
4853
- uses: actions/checkout@v4
54+
if: ${{ fromJson(inputs.github).event_name != 'pull_request_target' }}
55+
# we need to checkout the pr branch, not pr target (the default for pull_request_target)
56+
# user access check is done in calling workflow
57+
- uses: actions/checkout@v4
58+
if: ${{ fromJson(inputs.github).event_name == 'pull_request_target' }}
59+
with:
60+
ref: "refs/pull/${{ fromJson(inputs.github).event.number }}/merge"
4961

5062
- run: mkdir -p $TMPDIR
5163

64+
# do this early because it's fast and why not
65+
- name: Unlock encrypted secrets with git-crypt
66+
if: ${{ inputs.subscription }}
67+
run: |
68+
sudo apt-get update
69+
sudo apt-get install git-crypt
70+
echo "${GIT_CRYPT_KEY}" | base64 --decode > ./git-crypt-key
71+
git-crypt unlock ./git-crypt-key
72+
rm ./git-crypt-key
73+
env:
74+
GIT_CRYPT_KEY: ${{ secrets.GIT_CRYPT_KEY }}
75+
76+
- name: Add subscriptions from GitHub secret
77+
if: ${{ inputs.subscription }}
78+
run: |
79+
sudo mkdir -p /etc/pki/
80+
sudo cp -R ${PWD}/ci/secrets/pki/* /etc/pki/
81+
# https://access.redhat.com/solutions/5870841
82+
# https://github.com/containers/common/issues/1735
83+
printf "${PWD}/ci/secrets/run/secrets/rhsm:/etc/rhsm\n${PWD}/ci/secrets/run/secrets/etc-pki-entitlement:/etc/pki/entitlement\n${PWD}/ci/secrets/pki/consumer:/etc/pki/consumer\n" | sudo tee /usr/share/containers/mounts.conf
84+
85+
mkdir -p $HOME/.config/containers/
86+
sudo cp ${PWD}/ci/secrets/pull-secret.json $HOME/.config/containers/auth.json
87+
5288
# for bin/buildinputs in scripts/sandbox.py
5389
- uses: actions/setup-go@v5
5490
with:
@@ -264,7 +300,8 @@ jobs:
264300
(while true; do df -h | grep "${HOME}/.local/share/containers"; sleep 30; done) &
265301
266302
make ${{ inputs.target }}
267-
if: "${{ fromJson(inputs.github).event_name == 'pull_request' }}"
303+
if: "${{ fromJson(inputs.github).event_name == 'pull_request' ||
304+
fromJson(inputs.github).event_name == 'pull_request_target' }}"
268305
env:
269306
IMAGE_TAG: "${{ steps.calculated_vars.outputs.IMAGE_TAG }}"
270307
CONTAINER_BUILD_CACHE_ARGS: "--cache-from ${{ env.CACHE }}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
"name": "Build Notebooks (pr, RHEL images)"
3+
"on":
4+
"pull_request_target":
5+
6+
# BEWARE: This GitHub Actions workflow runs on pull_request_target, meaning it has access to our secrets
7+
# see https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-secrets
8+
# and https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
9+
10+
permissions:
11+
contents: read
12+
packages: read
13+
14+
env:
15+
# language=json
16+
contributors: |
17+
["atheo89", "andyatmiami", "caponetto", "daniellutz", "dibryant", "harshad16", "jesuino", "jiridanek", "jstourac", "paulovmr"]
18+
19+
jobs:
20+
gen:
21+
name: Generate job matrix
22+
runs-on: ubuntu-latest
23+
outputs:
24+
matrix: ${{ steps.gen.outputs.matrix }}
25+
has_jobs: ${{ steps.gen.outputs.has_jobs }}
26+
steps:
27+
28+
- name: Check permissions and deny untrusted users (this must be done FIRST, for security, before we checkout)
29+
if: ${{ !contains(fromJSON(env.contributors), github.actor) }}
30+
run: |
31+
echo "GitHub user ${{ github.actor }} is not a registered project contributor, not allowed to run actions on RHEL!"
32+
exit 1
33+
34+
# Here we are checking out the pull request, so that we can build from the new code
35+
# We can do this because we already checked that the submitting user is a contributor
36+
- uses: actions/checkout@v4
37+
if: ${{ github.event_name == 'pull_request_target' }}
38+
with:
39+
ref: "refs/pull/${{ github.event.number }}/merge"
40+
- uses: actions/checkout@v4
41+
if: ${{ github.event_name != 'pull_request_target' }}
42+
43+
- name: Determine targets to build based on changed files
44+
if: ${{ github.event_name == 'pull_request_target' }}
45+
run: |
46+
set -x
47+
git fetch --no-tags origin 'pull/${{ github.event.pull_request.number }}/head:${{ github.event.pull_request.head.ref }}'
48+
git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}'
49+
python3 ci/cached-builds/gen_gha_matrix_jobs.py \
50+
--from-ref 'origin/${{ github.event.pull_request.base.ref }}' \
51+
--to-ref '${{ github.event.pull_request.head.ref }}' \
52+
--rhel-images include-only
53+
id: gen
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
shell: bash
57+
58+
build:
59+
needs: ["gen"]
60+
strategy:
61+
fail-fast: false
62+
matrix: "${{ fromJson(needs.gen.outputs.matrix) }}"
63+
uses: ./.github/workflows/build-notebooks-TEMPLATE.yaml
64+
if: ${{ fromJson(needs.gen.outputs.has_jobs) }}
65+
with:
66+
target: "${{ matrix.target }}"
67+
github: "${{ toJSON(github) }}"
68+
subscription: "${{ matrix.subscription }}"
69+
secrets: inherit

.github/workflows/build-notebooks-pr.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
git fetch --no-tags origin '+refs/heads/${{ github.event.pull_request.base.ref }}:refs/remotes/origin/${{ github.event.pull_request.base.ref }}'
3434
python3 ci/cached-builds/gen_gha_matrix_jobs.py \
3535
--from-ref 'origin/${{ github.event.pull_request.base.ref }}' \
36-
--to-ref '${{ github.event.pull_request.head.ref }}'
36+
--to-ref '${{ github.event.pull_request.head.ref }}' \
37+
--rhel-images exclude
3738
id: gen
3839
env:
3940
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -49,4 +50,5 @@ jobs:
4950
with:
5051
target: "${{ matrix.target }}"
5152
github: "${{ toJSON(github) }}"
53+
subscription: "${{ matrix.subscription }}"
5254
secrets: inherit

.github/workflows/build-notebooks-push.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ jobs:
3939
with:
4040
target: "${{ matrix.target }}"
4141
github: "${{ toJSON(github) }}"
42+
subscription: "${{ matrix.subscription }}"
4243
secrets: inherit

.github/workflows/code-quality.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ jobs:
8080
steps:
8181
- uses: actions/checkout@v4
8282

83+
- name: Do not check secrets, they are encrypted
84+
run: rm -rf ./ci/secrets
85+
8386
- name: Validate YAML files (best code practices check included)
8487
id: validate-yaml-files
8588
run: |

.github/workflows/docs.yaml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
"name": "Docs (release notes)"
3+
"on":
4+
"push":
5+
"pull_request":
6+
"workflow_dispatch":
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
poetry_version: '1.8.3'
13+
14+
jobs:
15+
generate-releasenotes:
16+
name: Generate list of images for release notes
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Cache poetry in ~/.local
22+
uses: actions/cache/restore@v4
23+
id: cache-poetry-restore
24+
with:
25+
path: ~/.local
26+
key: "${{ runner.os }}-local-${{ env.poetry_version }}"
27+
28+
- name: Install poetry
29+
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
30+
run: pipx install poetry==${{ env.poetry_version }}
31+
env:
32+
PIPX_HOME: /home/runner/.local/pipx
33+
PIPX_BIN_DIR: /home/runner/.local/bin
34+
35+
- name: Check poetry is installed correctly
36+
run: poetry env info
37+
38+
- name: Save cache
39+
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
40+
uses: actions/cache/save@v4
41+
with:
42+
path: ~/.local
43+
key: ${{ steps.cache-poetry-restore.outputs.cache-primary-key }}
44+
45+
- name: Set up Python
46+
id: setup-python
47+
uses: actions/setup-python@v5
48+
with:
49+
python-version: '3.12'
50+
cache: 'poetry'
51+
52+
- name: Configure poetry
53+
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
54+
55+
- name: Install deps
56+
run: poetry install --sync
57+
58+
- name: Run the release notes script
59+
run: |
60+
set -Eeuxo pipefail
61+
poetry run ci/package_versions.py | tee ${GITHUB_STEP_SUMMARY}

0 commit comments

Comments
 (0)