|
5 | 5 | - main
|
6 | 6 | paths:
|
7 | 7 | - pyproject.toml
|
| 8 | + workflow_dispatch: |
| 9 | + |
8 | 10 | jobs:
|
9 |
| - check-publishability: |
| 11 | + publish-if-new-version: |
10 | 12 | if: github.repository != 'UWIT-IAM/example-flask-app'
|
11 | 13 | runs-on: ubuntu-latest
|
12 |
| - outputs: |
13 |
| - publishable: ${{ steps.check.outputs.publish }} |
14 | 14 | steps:
|
15 | 15 | - uses: actions/checkout@v4
|
16 | 16 | with:
|
17 | 17 | fetch-depth: 2
|
18 |
| - # note: this may not longer be necessary but the below job was failing April 2023 |
19 |
| - # and using an explicit token fixed that |
20 |
| - token: ${{ secrets.ACTIONS_PAT }} |
| 18 | + |
21 | 19 | # Only publish if the version has changed; otherwise, we would be
|
22 | 20 | # re-publishing existing stuff without updating the version, and that
|
23 | 21 | # could cause problems.
|
24 |
| - - run: | |
| 22 | + - name: Check if the change should be published |
| 23 | + run: | |
25 | 24 | set -x
|
26 | 25 | publishable=false
|
27 | 26 | diff=$(git diff HEAD:pyproject.toml HEAD~1:pyproject.toml) || exit 0
|
28 | 27 | echo "$diff" | grep '+version ='
|
29 |
| - if [[ "$?" == "0" ]] |
| 28 | + if [[ "$?" -ne 0 ]] |
30 | 29 | then
|
31 |
| - publishable=true |
| 30 | + echo 'Not publishable - skipping' |
| 31 | + exit 1 |
32 | 32 | fi
|
33 |
| - echo "::set-output name=publish::${publishable}" |
34 |
| - name: Check if the change should be published |
35 |
| - id: check |
36 |
| - build-and-publish: |
37 |
| - needs: [check-publishability] |
38 |
| - if: needs.check-publishability.outputs.publishable == 'true' |
39 |
| - runs-on: ubuntu-latest |
40 |
| - permissions: |
41 |
| - packages: write |
42 |
| - steps: |
43 |
| - - uses: actions/checkout@v4 |
| 33 | +
|
| 34 | + - uses: actions/setup-python@v4 |
44 | 35 | with:
|
45 |
| - token: ${{ secrets.ACTIONS_PAT }} |
| 36 | + python-version-file: pyproject.toml |
46 | 37 |
|
47 | 38 | - name: Install and configure poetry
|
48 | 39 | run: |
|
49 | 40 | pipx install poetry
|
50 | 41 | poetry config virtualenvs.create false
|
51 | 42 |
|
52 |
| - - name: Install app |
| 43 | + - name: Install package |
53 | 44 | run: poetry install
|
54 | 45 |
|
55 |
| - - run: sudo apt-get -y install jq |
| 46 | + - name: Install jq for fingerprinter |
| 47 | + run: sudo apt-get -y install jq |
| 48 | + |
| 49 | + - name: Auth to Google Cloud |
| 50 | + # important! this 'auth' is referenced as `steps.auth` on the next job |
| 51 | + id: auth |
| 52 | + # https://github.com/google-github-actions/auth#authenticating-via-service-account-key-json-1 |
| 53 | + uses: 'google-github-actions/auth@v1' |
| 54 | + with: |
| 55 | + credentials_json: '${{ secrets.MCI_GCLOUD_AUTH_JSON }}' |
| 56 | + token_format: 'access_token' |
56 | 57 |
|
57 |
| - - name: Log in to the Google container registry |
58 |
| - run: ./.github/scripts/gcr-login.sh |
59 |
| - env: |
60 |
| - # UPDATE: If this repository is not in the UWIT-IAM |
61 |
| - # org, you must ensure this secret exists, or update this |
62 |
| - # value to use a secret that does exist. The token |
63 |
| - # should be base64 encoded, and needs to be created by an |
64 |
| - # Aux project administrator. |
65 |
| - # |
66 |
| - # If you are running inside the UWIT-IAM namespace, |
67 |
| - # this is available for all repositories to use. |
68 |
| - GITHUB_TOKEN: ${{ secrets.GCR_TOKEN }} |
| 58 | + - name: Auth to Google Artifact Registry |
| 59 | + # https://github.com/google-github-actions/auth#authenticating-to-container-registry-and-artifact-registry |
| 60 | + # requires role: roles/iam.serviceAccountTokenCreator |
| 61 | + run: |- |
| 62 | + echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://us-docker.pkg.dev |
69 | 63 | - name: Create and push release image; deploy to dev
|
70 | 64 | run: |
|
| 65 | + # requires role: roles/artifactregistry.createOnPushWriter |
71 | 66 | ./scripts/build.sh --release $(poetry version -s) --cache --deploy dev
|
0 commit comments