-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: rewrite to react to modified files (#374)
* ci: switch to checking files changed * Add regenerate push to update branches * ci: switch to PR specific way of checkout for forks * Use built container if possible * ci: download from artifact if PR * ci: remove scheduled run and exec on new tags
- Loading branch information
Showing
10 changed files
with
183 additions
and
109 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: ci | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
changes: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
outputs: | ||
container: ${{ steps.filter.outputs.container }} | ||
outputs: ${{ steps.filter.outputs.outputs }} | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # @v2 | ||
if: ${{ github.event_name == 'push' }} | ||
with: | ||
fetch-depth: 0 | ||
|
||
# For pull requests it's not necessary to checkout the code | ||
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 | ||
id: filter | ||
with: | ||
filters: | | ||
container: | ||
- '.github/**' | ||
- 'container/**' | ||
outputs: | ||
- '.github/**' | ||
- 'outputs/**.sh' | ||
container: | ||
if: ${{ needs.changes.outputs.container == 'true' }} | ||
needs: changes | ||
uses: ./.github/workflows/container.yml | ||
|
||
outputs: | ||
if: ${{ needs.changes.outputs.outputs == 'true' }} | ||
needs: [ changes, container ] | ||
uses: ./.github/workflows/outputs.yml |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Build Tutorial Container | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
packages: write | ||
|
||
steps: | ||
- name: Remove pre-installed apps to make space for build | ||
run: | | ||
sudo apt-get remove -y '^llvm-.*' | ||
sudo apt-get remove -y '^dotnet-.*' | ||
sudo apt-get remove -y 'php.*' | ||
sudo apt-get remove -y '^mongodb-.*' | ||
sudo apt-get remove -y '^mysql-.*' | ||
sudo apt-get autoremove -y | ||
sudo apt-get clean | ||
sudo rm -rf /usr/share/dotnet/ | ||
sudo rm -rf /usr/local/share/powershell | ||
sudo rm -rf /usr/local/share/chromium | ||
sudo rm -rf /usr/local/lib/android | ||
sudo rm -rf /usr/local/lib/node_modules | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@5927c834f5b4fdf503fca6f4c7eccda82949e1ee | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 | ||
|
||
- name: Login to GitHub Container Registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Generate Container Metadata | ||
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | ||
with: | ||
images: ghcr.io/spack/tutorial | ||
|
||
- name: Build & Push | ||
uses: docker/build-push-action@1ca370b3a9802c92e886402e0dd88098a2533b12 | ||
env: | ||
DOCKER_BUILD_SUMMARY: false | ||
DOCKER_BUILD_RECORD_UPLOAD: false | ||
with: | ||
context: "{{defaultContext}}:container" | ||
platforms: linux/amd64 | ||
cache-from: type=registry,ref=ghcr.io/spack/tutorial:buildcache | ||
cache-to: ${{ github.ref == 'refs/heads/main' && 'type=registry,ref=ghcr.io/spack/tutorial:buildcache,mode=max' || '' }} | ||
outputs: ${{ github.ref != 'refs/heads/main' && 'type=docker,dest=/tmp/tutorial-container.tar' || 'type=registry' }} | ||
|
||
- name: Upload container as artifact for PRs | ||
if: github.event_name == 'pull_request' | ||
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b | ||
with: | ||
name: tutorial-container | ||
path: /tmp/tutorial-container.tar | ||
retention-days: 1 | ||
compression-level: 9 |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Generate outputs | ||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
re-generate: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Remove pre-installed apps to make space for build | ||
run: | | ||
sudo apt-get remove -y '^llvm-.*' | ||
sudo apt-get remove -y '^dotnet-.*' | ||
sudo apt-get autoremove -y | ||
sudo rm -rf /usr/share/dotnet/ | ||
sudo docker system prune -af | ||
- name: Checkout (Push) | ||
if: github.event_name != 'pull_request' | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
|
||
- name: Checkout (PR) | ||
if: github.event_name == 'pull_request' | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
|
||
- name: Download container from artifact if PR | ||
if: github.event_name == 'pull_request' | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 | ||
with: | ||
name: tutorial-container | ||
path: /tmp | ||
|
||
- name: Import container from PR artifact | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
docker load --input /tmp/tutorial-container.tar | ||
docker tag $(docker image ls -q) ghcr.io/spack/tutorial:latest | ||
docker image ls -a | ||
- name: Re-generate outputs from tutorial scripts | ||
run: | | ||
chmod -R a+w outputs | ||
make -C outputs -j $(nproc) DOCKER_RUN_OPTS="-e COLUMNS=94 -e LINES=24" container=ghcr.io/spack/tutorial | ||
- name: Show diff of modified files | ||
run: | | ||
git diff HEAD . | ||
- name: Push modified files to branch | ||
if: ( github.event_name == 'pull_request' && ! github.event.pull_request.head.repo.fork ) || github.event_name != 'pull_request' | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git add . | ||
git commit -m "Update generated outputs on behalf of [@${{ github.actor }}]" | ||
git push |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.