Skip to content

Commit 9397383

Browse files
committed
Update GitHub Actions workflows
* Fix build.yml to trigger only on specific ci/ files rather than ci/** * Remove pull_request push to Docker Hub; PRs now build-only, push on merge to main or via workflow_dispatch * Fix "Export Full Conda Environment" step in both build workflows to reference the image tag just built rather than the stale :main tag * Update all actions to latest versions * Switch bot commits from personal account to github-actions[bot] * Remove UPDATE_LOCKFILE_TOKEN PAT; GITHUB_TOKEN with contents: write is sufficient since we no longer need to trigger downstream workflows * Add PR comment after lock file update directing users to workflow_dispatch to build a test image
1 parent 981c06c commit 9397383

3 files changed

Lines changed: 40 additions & 24 deletions

File tree

.github/workflows/build-stable.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ jobs:
1010
run:
1111
shell: bash -l {0}
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v4
1414
- name: "Set Job Environment Variables"
1515
run: |
1616
echo "RELEASE_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
1717
1818
- name: "Set up QEMU"
19-
uses: docker/setup-qemu-action@v2
19+
uses: docker/setup-qemu-action@v4
2020

2121
- name: "Set up Docker Buildx"
22-
uses: docker/setup-buildx-action@v2
22+
uses: docker/setup-buildx-action@v4
2323

2424
- name: "Login to Docker Hub"
25-
uses: docker/login-action@v2
25+
uses: docker/login-action@v4.1.0
2626
with:
2727
username: openscapes
2828
password: ${{ secrets.DOCKERHUB_TOKEN }}
2929

3030
- name: "Build and push"
31-
uses: docker/build-push-action@v4
31+
uses: docker/build-push-action@v7.1.0
3232
with:
3333
context: ci
3434
push: true

.github/workflows/build.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,27 @@ on:
66
- main
77
- dev
88
paths:
9-
# build if anything in ci/ changes except only environment.yml because
10-
# environment-lock.yml needs to be built first by create-conda-lock.yml
11-
- 'ci/**'
12-
- '!ci/environment.yml'
9+
- 'ci/conda-lock.yml'
10+
- 'ci/Dockerfile'
11+
- 'ci/apt.txt'
12+
- 'ci/postBuild'
13+
- 'ci/start'
14+
- 'ci/install-vscode-ext.sh'
15+
- 'ci/vscode-extensions.txt'
1316
- '.github/workflows/build.yml'
1417

1518
pull_request:
1619
branches:
1720
- main
1821
- dev
1922
paths:
20-
# build if anything in ci/ changes except only environment.yml because
21-
# environment-lock.yml needs to be built first by create-conda-lock.yml
22-
- 'ci/**'
23-
- '!ci/environment.yml'
23+
- 'ci/conda-lock.yml'
24+
- 'ci/Dockerfile'
25+
- 'ci/apt.txt'
26+
- 'ci/postBuild'
27+
- 'ci/start'
28+
- 'ci/install-vscode-ext.sh'
29+
- 'ci/vscode-extensions.txt'
2430
- '.github/workflows/build.yml'
2531

2632
workflow_dispatch:
@@ -41,24 +47,25 @@ jobs:
4147
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
4248
4349
- name: "Set up QEMU"
44-
uses: docker/setup-qemu-action@v2
50+
uses: docker/setup-qemu-action@v4
4551

4652
- name: "Set up Docker Buildx"
47-
uses: docker/setup-buildx-action@v2
53+
uses: docker/setup-buildx-action@v4
4854

4955
- name: "Login to Docker Hub"
50-
uses: docker/login-action@v2
56+
uses: docker/login-action@v4.1.0
5157
with:
5258
username: openscapes
5359
password: ${{ secrets.DOCKERHUB_TOKEN }}
5460

5561
- name: "Build and push"
56-
uses: docker/build-push-action@v4
62+
uses: docker/build-push-action@v7.1.0
5763
with:
5864
context: ci
59-
push: true
65+
push: ${{ github.event_name != 'pull_request' }}
6066
tags: openscapes/python:latest, openscapes/python:${{ env.DOCKER_TAG }}
6167

6268
- name: Export Full Conda Environment
69+
if: github.event_name != 'pull_request'
6370
run: |
64-
docker run openscapes/python:main conda list --export
71+
docker run openscapes/python:${{ env.DOCKER_TAG }} conda list --export

.github/workflows/create-conda-lock.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
workflow_dispatch:
1818
permissions:
1919
contents: write
20+
pull-requests: write
2021
jobs:
2122
build:
2223
runs-on: ubuntu-latest
@@ -26,7 +27,7 @@ jobs:
2627
with:
2728
ref: ${{ github.head_ref }}
2829
- name: install conda-lock with micromamba
29-
uses: mamba-org/setup-micromamba@main
30+
uses: mamba-org/setup-micromamba@v2
3031
with:
3132
environment-name: locker
3233
create-args: conda-lock
@@ -37,12 +38,20 @@ jobs:
3738
run: |
3839
conda-lock lock --mamba --file environment.yml --platform linux-64
3940
- name: commit changes to tracked files
40-
env:
41-
GH_TOKEN: ${{ secrets.UPDATE_LOCKFILE_TOKEN }}
41+
id: commit
4242
run: |
4343
if [[ $(git ls-files --modified) ]]; then
44-
git config --global user.name 'ateucher'
45-
git config --global user.email '2816635+ateucher@users.noreply.github.com'
44+
git config --global user.name 'github-actions[bot]'
45+
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
4646
git commit --all --message "[bot] autogenerated conda-lock files"
4747
git push
48+
echo "committed=true" >> $GITHUB_OUTPUT
4849
fi
50+
51+
- name: comment on PR
52+
if: steps.commit.outputs.committed == 'true' && github.event_name == 'pull_request'
53+
uses: peter-evans/create-or-update-comment@v4
54+
with:
55+
issue-number: ${{ github.event.pull_request.number }}
56+
body: |
57+
`conda-lock.yml` has been updated. To build and test a Docker image from this branch, trigger the [Build and push Docker image](../actions/workflows/build.yml) workflow manually and select this branch.

0 commit comments

Comments
 (0)