|
| 1 | +name: Nightly Upstream Snapshot Build |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "21 3 * * *" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +env: |
| 9 | + BRANCH_NAME: nightly-dependency-updates |
| 10 | + |
| 11 | +jobs: |
| 12 | + update-and-create-pr: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + outputs: |
| 15 | + has_changes: ${{ steps.check_changes.outputs.has_changes }} |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout repository |
| 19 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5.0.0 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + |
| 24 | + - name: Check if nightly branch already exists |
| 25 | + run: | |
| 26 | + if git ls-remote --exit-code --heads origin "$BRANCH_NAME"; then |
| 27 | + echo "Branch $BRANCH_NAME already exists. Skipping run to avoid conflicts." |
| 28 | + echo "Please merge or close the existing PR before the next nightly run." |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + |
| 32 | + - name: Configure git and create branch |
| 33 | + run: | |
| 34 | + git config --local user.email "[email protected]" |
| 35 | + git config --local user.name "GitHub Action" |
| 36 | + git checkout -b "$BRANCH_NAME" |
| 37 | + |
| 38 | + - name: Set up Node.js |
| 39 | + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 #v5.0.0 |
| 40 | + with: |
| 41 | + node-version: '18' |
| 42 | + |
| 43 | + - name: Install dependencies |
| 44 | + run: npm install |
| 45 | + |
| 46 | + - name: Update dependencies |
| 47 | + run: node scripts/update_dependencies.js |
| 48 | + |
| 49 | + - name: Check for changes and create PR |
| 50 | + id: check_changes |
| 51 | + run: | |
| 52 | + if git diff --quiet; then |
| 53 | + echo "No dependency updates needed" |
| 54 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 55 | + else |
| 56 | + echo "Dependencies were updated" |
| 57 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 58 | + |
| 59 | + git add aws-distro-opentelemetry-node-autoinstrumentation/package.json |
| 60 | + git commit -m "chore: update OpenTelemetry dependencies to latest versions" |
| 61 | + git push origin "$BRANCH_NAME" |
| 62 | + |
| 63 | + gh pr create \ |
| 64 | + --title "Nightly dependency update: OpenTelemetry packages to latest versions" \ |
| 65 | + --body "Automated update of OpenTelemetry dependencies to their latest available versions." \ |
| 66 | + --base main \ |
| 67 | + --head "$BRANCH_NAME" |
| 68 | + fi |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments