Skip to content

Commit

Permalink
Fixes creating temp pr version
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Mar 9, 2024
1 parent 1add133 commit 26b594f
Showing 1 changed file with 65 additions and 33 deletions.
98 changes: 65 additions & 33 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,37 @@ concurrency:
cancel-in-progress: true

jobs:
build-minimal-notebook:
get-issue-number:
runs-on: ubuntu-latest
name: Build minimal-notebook
name: Get PR number
permissions:
packages: write
contents: read
outputs:
pr-number: "${{ steps.pr-number.outputs.pr-number }}"
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
- uses: actions/github-script@v6
id: get-issue-number
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-python@v5
with:
python-version: '3.9'
- id: get-version
run: |
pip install tbump
pushd dockerfiles/minimal-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/minimal-notebook
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }}
script: |
if (context.issue.number) {
return context.issue.number;
} else {
return (
await github.rest.repos.listPullRequestAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
}).data[0].number;
}
result-encoding: string
- id: pr-number
run: echo "pr-number=${{ steps.get-issue-number.outputs.result }}" >> $GITHUB_OUTPUT

build-climate-notebook:
build-minimal-notebook:
needs:
- build-minimal-notebook
- get-issue-number
runs-on: ubuntu-latest
name: Build climate-notebook
name: Build minimal-notebook
permissions:
packages: write
steps:
Expand All @@ -67,13 +64,48 @@ jobs:
python-version: '3.9'
- id: get-version
run: |
pip install tbump
pushd dockerfiles/climate-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "version=pr-${{ needs.get-issue-number.outputs.pr-number }}" >> $GITHUB_OUTPUT
else
pip install tbump
pushd dockerfiles/minimal-notebook
echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
fi
- uses: docker/build-push-action@v5
with:
cache-from: type=gha
cache-to: type=gha,mode=max
context: dockerfiles/climate-notebook
push: ${{ github.event_name == 'push' }}
tags: ghcr.io/esgf-nimbus/climate-notebook:${{ steps.get-version.outputs.version }}
context: dockerfiles/minimal-notebook
push: true
tags: ghcr.io/esgf-nimbus/minimal-notebook:${{ steps.get-version.outputs.version }}

# build-climate-notebook:
# needs:
# - build-minimal-notebook
# runs-on: ubuntu-latest
# name: Build climate-notebook
# permissions:
# packages: write
# steps:
# - uses: actions/checkout@v4
# - uses: docker/setup-buildx-action@v3
# - uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - uses: actions/setup-python@v5
# with:
# python-version: '3.9'
# - id: get-version
# run: |
# pip install tbump
# pushd dockerfiles/climate-notebook
# echo "version=$(tbump current-version)" >> $GITHUB_OUTPUT
# - uses: docker/build-push-action@v5
# with:
# cache-from: type=gha
# cache-to: type=gha,mode=max
# context: dockerfiles/climate-notebook
# push: ${{ github.event_name == 'push' }}
# tags: ghcr.io/esgf-nimbus/climate-notebook:${{ steps.get-version.outputs.version }}

0 comments on commit 26b594f

Please sign in to comment.