Skip to content

Commit

Permalink
Allow CI to access secrets once PR is approved (ecmwf#75)
Browse files Browse the repository at this point in the history
* Auto-format with prettier v2.8.8

* Allow CI to access secrets once PR is approved
  • Loading branch information
dtip authored May 4, 2023
1 parent 9b882a8 commit 0ad7f77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
56 changes: 31 additions & 25 deletions .github/workflows/check-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,24 @@ name: Check and publish

on:
push:
branches: [ master ]
branches: [master]

pull_request:
branches: [ master ]
branches: [master]

# Trigger on public pull request approval
pull_request_target:
types: [labeled]

release:
types: [created]


jobs:
quality-checks:
name: Code QA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: pip install black flake8 isort
- run: black --version
- run: isort --version
Expand All @@ -27,6 +30,7 @@ jobs:

platform-checks:
needs: quality-checks
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action != 'labeled' || github.event.label.name == 'approved-for-ci' }}
strategy:
fail-fast: false
matrix:
Expand All @@ -39,7 +43,9 @@ jobs:
timeout-minutes: 20

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- uses: actions/setup-python@v2
with:
Expand All @@ -64,26 +70,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
twine upload dist/*
- name: Notify climetlab
uses: mvasigh/dispatch-action@main
with:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
twine upload dist/*
- name: Notify climetlab
uses: mvasigh/dispatch-action@main
with:
token: ${{ secrets.NOTIFY_ECMWFLIBS }}
repo: climetlab
owner: ecmwf
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/label-public-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Manage labels of pull requests that originate from forks
name: label-public-pr

on:
pull_request_target:
types: [opened, synchronize]

jobs:
label:
uses: ecmwf-actions/reusable-workflows/.github/workflows/label-pr.yml@v2

0 comments on commit 0ad7f77

Please sign in to comment.