Skip to content

Sweep Experiments

Sweep Experiments #34

# Executes `amp sweep-experiments` on a schedule.
# If experiments are swept, a PR is created.
name: Sweep Experiments
on:
schedule:
# First day of the month at 00:00:00
- cron: '0 0 1 * *'
jobs:
sweep-experiments:
if: github.repository == 'ampproject/amphtml'
name: Sweep Experiments
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set Up Node
uses: actions/[email protected]
- name: Set Up Environment
run: sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
- name: Install Dependencies
run: npm ci
- name: Sweep
id: sweep
run: |
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
amp sweep-experiments
title=$(git log -1 --format=%s)
title="${title//'%'/'%25'}"
title="${title//$'\n'/'%0A'}"
title="${title//$'\r'/'%0D'}"
echo "::set-output name=title::$(echo "$title")"
body=$(git log -1 --format=%b)
body="${body//'%'/'%25'}"
body="${body//$'\n'/'%0A'}"
body="${body//$'\r'/'%0D'}"
echo "::set-output name=body::$(echo "$body")"
hash=$(git log -1 --format=%h)
hash="${hash//'%'/'%25'}"
hash="${hash//$'\n'/'%0A'}"
hash="${hash//$'\r'/'%0D'}"
echo "::set-output name=branch::$(echo "sweep-experiments-${hash}")"
- name: Create Pull Request
id: pull-request
uses: peter-evans/create-pull-request@v3
with:
draft: true
title: ${{ steps.sweep.outputs.title }}
body: ${{ steps.sweep.outputs.body }}
branch: ${{ steps.sweep.outputs.branch }}
- name: Comment on Pull Request
if: ${{ steps.pull-request.outputs.pull-request-number }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ steps.pull-request.outputs.pull-request-number }}
body: |
You may checkout this pull request to follow-up manually:
```
git checkout -t upstream/${{ steps.sweep.outputs.branch }}
```