add synchornize action #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test data and merge to production | |
on: | |
push: | |
branches: main | |
env: | |
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }} | |
MERGE_FROM_BRANCH: main | |
MERGE_TO_BRANCH: production | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Hakai Tests | |
run: | | |
python -m pip install --upgrade pip | |
pip install git+https://HakaiInstitute:${{secrets.CI_TOKEN}}@github.com/HakaiInstitute/hakai-datasets-repo-standard-tests.git | |
- name: Test with pytest | |
run: | | |
pytest --pyargs hakai_data_repo_tests | |
production-merge: | |
runs-on: ubuntu-latest | |
env: | |
PR_STATUS: '' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set PR status as environment variable | |
run: | | |
echo 'PR_STATUS<<EOF' >> $GITHUB_ENV | |
gh pr status >> $GITHUB_ENV | |
echo 'EOF' >> $GITHUB_ENV | |
- name: Create Pull Request | |
if: ${{contains(env.PR_STATUS, 'There is no pull request associated with [main]')}} | |
run: | | |
gh pr create -H ${{env.MERGE_FROM_BRANCH}} -B ${{env.MERGE_TO_BRANCH}} --title "Merge latest changes to main into production branch" --body-file ".github/workflows/production-merge-pull-request-body.md" | |
merge: | |
runs-on: ubuntu-latest | |
needs: [tests, production-merge] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Auto-merge pull requests | |
run: gh pr merge --auto --merge |