diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000..2b74c94 --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,7 @@ +# GitHub Actions Continuous Integration workflows + +- binder.yaml - Adds a Binder badge to Pull Requests that are newly opened +- build.yaml - Build and push docker container images to a docker registry +- conda-lock-command.yml - Refresh conda-lock files by writing `/condalock` in a Pull Request comment +- slash-command-dispatch.yml - ChatOps that looks for slash commands in Pull Requests to trigger automated scripts +- test.yaml - Test building docker container images in a Pull Request diff --git a/.github/workflows/conda-lock-command.yml b/.github/workflows/conda-lock-command.yml new file mode 100644 index 0000000..4fa9b7f --- /dev/null +++ b/.github/workflows/conda-lock-command.yml @@ -0,0 +1,69 @@ +# Runs conda-lock against environment.yml for reproducible environments +# Runs on any opened PR +name: Conda Lock + +on: + repository_dispatch: + types: [condalock-command] + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +jobs: + condalock: + permissions: + contents: write # for Git to git push + runs-on: ubuntu-latest + timeout-minutes: 15 + defaults: + run: + shell: bash -l {0} + + steps: + # Generate token from CryoInTheCloud bot + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + + # Checkout the pull request branch + - name: Checkout Repository + uses: actions/checkout@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} + ref: ${{ github.event.client_payload.pull_request.head.ref }} + + # Setup Python environment + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + # Install conda-lock library + - name: Install conda-lock + run: pip install conda-lock + + # Run "conda-lock" for linux-64 only + - name: Run conda-lock + run: | + conda-lock lock --mamba --kind explicit --file environment.yml --platform linux-64 + + # Commit the change to the PR branch if any changes + - name: Commit condalock files to PR + run: | + if [[ $(git ls-files --modified --others) ]]; then + git config --global user.name 'actions-bot' + git config --global user.email '58130806+actions-bot@users.noreply.github.com' + git commit --all --message "[condalock-command] autogenerated conda-lock files" + git push + fi + + # Add an emoji reaction to comment to indicate the script completed successfully + - name: Add reaction + uses: peter-evans/create-or-update-comment@v2 + with: + token: ${{ steps.generate-token.outputs.token }} + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + comment-id: ${{ github.event.client_payload.github.payload.comment.id }} + reaction-type: hooray diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml new file mode 100644 index 0000000..c16ca89 --- /dev/null +++ b/.github/workflows/slash-command-dispatch.yml @@ -0,0 +1,34 @@ +name: Slash Command Dispatch + +on: + issue_comment: + types: [created] + # Add "edited" type for test purposes. Where possible, avoid using to prevent processing unnecessary events. + # types: [created, edited] + +permissions: # added using https://github.com/step-security/secure-workflows + contents: read + +jobs: + slashCommandDispatch: + permissions: + pull-requests: write # for peter-evans/slash-command-dispatch to create PR reaction + if: ${{ github.event.issue.pull_request }} + runs-on: ubuntu-latest + steps: + # Generate token from CryoInTheCloud bot + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.APP_PRIVATE_KEY }} + + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + reaction-token: ${{ secrets.GITHUB_TOKEN }} + commands: | + condalock + issue-type: pull-request + permission: none diff --git a/conda-linux-64.lock b/conda-linux-64.lock new file mode 100644 index 0000000..688a24f --- /dev/null +++ b/conda-linux-64.lock @@ -0,0 +1,2 @@ +# Generated by conda-lock. +# platform: linux-64