Skip to content

Maximum Likelihood Estimation - how neural networks learn | Chan`s Jupyter #64

Maximum Likelihood Estimation - how neural networks learn | Chan`s Jupyter

Maximum Likelihood Estimation - how neural networks learn | Chan`s Jupyter #64

Workflow file for this run

name: Upgrade fastpages
on:
issues:
types: [opened]
jobs:
check_credentials:
if: |
(github.repository != 'fastai/fastpages') &&
(github.event.issue.title == '[fastpages] Automated Upgrade')
runs-on: ubuntu-latest
steps:
- name: see payload
run: |
echo "FULL PAYLOAD:\n${PAYLOAD}\n"
echo "PR_PAYLOAD PAYLOAD:\n${PR_PAYLOAD}"
env:
PAYLOAD: ${{ toJSON(github.event) }}
PR_PAYLOAD: ${{ github.event.pull_request }}
- name: Comment on issue if sufficient access does not exist
if: |
(github.event.issue.author_association != 'OWNER') &&
(github.event.issue.author_association != 'COLLABORATOR') &&
(github.event.issue.author_association != 'MEMBER')
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var permission_level = process.env.permission_level;
var url = 'https://help.github.com/en/github/setting-up-and-managing-your-github-user-account/permission-levels-for-a-user-account-repository#collaborator-access-on-a-repository-owned-by-a-user-account'
var msg = `You must have the [permission level](${url}) of either an **OWNER**, **COLLABORATOR** or **MEMBER** to instantiate an upgrade request. Your permission level is ${permission_level}`
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: msg
})
github.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})
throw msg;
env:
permission_level: ${{ github.event.issue.author_association }}
upgrade:
needs: [check_credentials]
if: |
(github.repository != 'fastai/fastpages') &&
(github.event.issue.title == '[fastpages] Automated Upgrade') &&
(github.event.issue.author_association == 'OWNER' || github.event.issue.author_association == 'COLLABORATOR' || github.event.issue.author_association == 'MEMBER')
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: checkout latest fastpages
uses: actions/checkout@v2
with:
repository: 'fastai/fastpages'
path: 'new_files'
persist-credentials: false
- name: copy this repo's contents
uses: actions/checkout@v2
with:
path: 'current_files'
persist-credentials: false
- name: compare versions
id: check_version
run: |
from pathlib import Path
new_version = Path('new_files/_fastpages_docs/version.txt')
old_version = Path('current_files/_fastpages_docs/version.txt')
if old_version.exists():
old_num = old_version.read_text().strip()
new_num = new_version.read_text().strip()
print(f'Old version: {old_num}')
print(f'New version: {new_num}')
if old_num == new_num:
print('::set-output name=vbump::false')
else:
print('::set-output name=vbump::true')
else:
print('::set-output name=vbump::true')
shell: python
- name: copy new files
if: steps.check_version.outputs.vbump == 'true'
run: |
# remove files you don't want to copy from current version of fastpages
cd new_files
rm -rf _posts _notebooks _word images
rm *.md CNAME action.yml _config.yml index.html LICENSE
rm _pages/*.md
rm .github/workflows/chatops.yaml
rm .github/workflows/docker.yaml
rm .github/ISSUE_TEMPLATE/bug.md .github/ISSUE_TEMPLATE/feature_request.md
# copy new files from fastpages into your repo
for file in $(ls | egrep -v "(assets|_sass)"); do
if [[ -f "$file" ]] || [[ -d "$file" ]]
then
echo "copying $file";
cp -r $file ../current_files;
fi
done
# copy custom-variables.scss if doesn't exist
if [ ! -f "../current_files/_sass/minima/custom-variables.scss" ]; then
cp _sass/minima/custom-variables.scss ../current_files/_sass/minima/
fi
# copy select files in assets and _sass
cp -r assets/js ../current_files/assets
cp -r assets/badges ../current_files/assets
cp _sass/minima/fastpages-styles.scss ../current_files/_sass/minima/
cp _sass/minima/fastpages-dracula-highlight.scss ../current_files/_sass/minima/
# copy action workflows
cp -r .github ../current_files
# install dependencies
pip3 install pyyaml
- name: sync baseurl
if: steps.check_version.outputs.vbump == 'true'
run: |
import re, os, yaml
from pathlib import Path
from configparser import ConfigParser
settings = ConfigParser()
# specify location of config files
nwo = os.getenv('GITHUB_REPOSITORY')
username, repo_name = nwo.split('/')
settings_path = Path('current_files/_action_files/settings.ini')
config_path = Path('current_files/_config.yml')
setup_pr_path = Path('current_files/_fastpages_docs/_setup_pr_template.md')
upgrade_pr_path = Path('current_files/_fastpages_docs/_upgrade_pr.md')
assert settings_path.exists(), 'Did not find _action_files/settings.ini in your repository!'
assert config_path.exists(), 'Did not find _config.yml in your repository!'
assert setup_pr_path.exists(), 'Did not find_fastpages_docs/_setup_pr_template.md in the current directory!'
assert upgrade_pr_path.exists(), 'Did not find _fastpages_docs/_upgrade_pr.md in your repository!'
# read data from config files
settings.read(settings_path)
with open(config_path, 'r') as cfg:
config = yaml.load(cfg)
# sync value for baseurl b/w config.yml and settings.ini
settings['DEFAULT']['baseurl'] = config['baseurl']
with open(settings_path, 'w') as stg:
settings.write(stg)
# update PR templates
setup_pr = setup_pr_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
setup_pr_path.write_text(setup_pr)
upgrade_pr = upgrade_pr_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
upgrade_pr_path.write_text(upgrade_pr)
shell: python
- uses: webfactory/[email protected]
if: steps.check_version.outputs.vbump == 'true'
with:
ssh-private-key: ${{ secrets.SSH_DEPLOY_KEY }}
- name: push changes to branch
if: steps.check_version.outputs.vbump == 'true'
run: |
# commit changes
cd current_files
git config --global user.email "${GH_USERNAME}@users.noreply.github.com"
git config --global user.name "${GH_USERNAME}"
git remote remove origin
git remote add origin "[email protected]:${GITHUB_REPOSITORY}.git"
git add _action_files/settings.ini
git checkout -b fastpages-automated-upgrade
git add -A
git commit -m'upgrade fastpages'
git push -f --set-upstream origin fastpages-automated-upgrade main
env:
GH_USERNAME: ${{ github.event.issue.user.login }}
- name: Open a PR
if: steps.check_version.outputs.vbump == 'true'
id: pr
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var fs = require('fs');
var contents = fs.readFileSync('current_files/_fastpages_docs/_upgrade_pr.md', 'utf8');
github.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '[fastpages] Update repo with changes from fastpages',
head: 'fastpages-automated-upgrade',
base: 'main',
body: `${contents}`
})
.then(result => console.log(`::set-output name=pr_num::${result.data.number}`))
- name: Comment on issue if failure
if: failure() && (steps.check_version.outputs.vbump == 'true')
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var pr_num = process.env.PR_NUM;
var repo = process.env.REPO
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `An error occurred when attempting to open a PR to update fastpages. See the [Actions tab of your repo](https://github.com/${repo}/actions) for more details.`
})
env:
PR_NUM: ${{ steps.pr.outputs.pr_num }}
REPO: ${{ github.repository }}
- name: Comment on issue
if: steps.check_version.outputs.vbump == 'true'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var pr_num = process.env.PR_NUM;
var repo = process.env.REPO
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Opened PR https://github.com/${repo}/pull/${pr_num} to assist with updating fastpages.`
})
env:
PR_NUM: ${{ steps.pr.outputs.pr_num }}
REPO: ${{ github.repository }}
- name: Comment on issue if version has not changed
if: steps.check_version.outputs.vbump == 'false'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Your version of fastpages is up to date. There is nothing to change.`
})
- name: Close Issue
if: always()
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
state: 'closed'
})