Skip to content

Update rips from main ResInsight repository #665

Update rips from main ResInsight repository

Update rips from main ResInsight repository #665

name: Update rips from main ResInsight repository
on:
push:
workflow_dispatch:
schedule:
- cron: '0 6 * * *' # Daily at 6 AM
jobs:
download-artifact:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up authentication
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
run: |
echo "Authenticated with PAT"
- name: Get latest successful workflow run
id: get_run
run: |
curl -H "Authorization: token ${{ secrets.PAT }}" \
"https://api.github.com/repos/OPM/ResInsight/actions/workflows/ResInsightWithCache.yml/runs?branch=dev&status=completed&per_page=100" \
| jq '.workflow_runs[] | select(.conclusion=="success") | .id' \
| head -n 1 > run_id.txt
echo "run_id=$(cat run_id.txt)" >> $GITHUB_ENV
- name: Download artifact metadata, find url for 'python-distribution'
id: get_artifact
run: |
mkdir -p downloaded_artifacts
curl -H "Authorization: token ${{ secrets.PAT }}" \
-L https://api.github.com/repos/OPM/ResInsight/actions/runs/${{ env.run_id }}/artifacts \
-o downloaded_artifacts/artifacts.json
# Find artifact with name python-distribution
ARTIFACT_URL=$(jq -r '.artifacts[] | select(.name=="python-distribution") | .archive_download_url' downloaded_artifacts/artifacts.json)
echo "artifact_url=$ARTIFACT_URL" >> $GITHUB_ENV
- name: Download artifact file
run: |
curl -H "Authorization: token ${{ secrets.PAT }}" \
-L "${{ env.artifact_url }}" \
-o downloaded_artifacts/artifact.zip
- name: Update docs/rips folder from downloaded artifacts
run: |
echo "Downloaded files:"
cd downloaded_artifacts
unzip artifact.zip
cd ..
mkdir upstream_rips
tar -xzf downloaded_artifacts/rips*.tar.gz -C upstream_rips
# ls upstream_rips/rips*
rm -rf ./docs/rips
cp -r upstream_rips/rips*/rips ./docs/
# ls -R ./docs/rips
- name: Download proto files from ResInsight repository
run: |
# Create proto directory
mkdir -p docs/proto
# Get list of proto files from the GrpcProtos directory
curl -H "Authorization: token ${{ secrets.PAT }}" \
https://api.github.com/repos/OPM/ResInsight/contents/GrpcInterface/GrpcProtos?ref=dev \
-o proto_files.json
# Download each proto file
for file in $(jq -r '.[] | select(.name | endswith(".proto")) | .download_url' proto_files.json); do
filename=$(basename "$file")
echo "Downloading $filename"
curl -H "Authorization: token ${{ secrets.PAT }}" \
-L "$file" \
-o "docs/proto/$filename"
done
# Clean up
rm proto_files.json
echo "Proto files downloaded:"
ls -la docs/proto/
# ProtobufStructures.rst, the class/enum index and the Python example
# pages are generated at Sphinx build time (docs/source/conf.py), so this
# workflow only ships the updated rips package and .proto files.
- uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update rips module and proto files"
title: "Automated updates from ResInsight repository"
branch: artifact-update-rips
branch-suffix: random