|
| 1 | +name: new-plugin |
| 2 | +on: |
| 3 | + push: |
| 4 | + branch: |
| 5 | + - "main" |
| 6 | + paths: |
| 7 | + - "plugins/**" |
| 8 | + |
| 9 | +jobs: |
| 10 | + job1: |
| 11 | + name: TODO name the job |
| 12 | + runs-on: ubuntu-latest |
| 13 | + timeout-minutes: 40 |
| 14 | + if: github.repository == 'nix-community/nixvim' |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ssh-key: ${{ secrets.CI_UPDATE_SSH_KEY }} |
| 21 | + |
| 22 | + - name: Install Nix |
| 23 | + uses: cachix/install-nix-action@v26 |
| 24 | + with: |
| 25 | + nix_path: nixpkgs=channel:nixos-unstable |
| 26 | + github_access_token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + |
| 28 | + - name: Get plugins info |
| 29 | + run: | |
| 30 | + OLD="$( |
| 31 | + nix eval 'github:${{ github.repository }}/${{ github.event.before }}#nixvimConfiguration.options.plugins' \ |
| 32 | + --apply 'builtins.attrNames' \ |
| 33 | + --json |
| 34 | + )" |
| 35 | + NEW="$( |
| 36 | + nix eval '.#nixvimConfiguration.options.plugins' \ |
| 37 | + --apply 'builtins.attrNames' \ |
| 38 | + --json |
| 39 | + )" |
| 40 | + # TODO: compare OLD and NEW |
| 41 | +
|
| 42 | + - name: Get PR info |
| 43 | + env: |
| 44 | + GH_TOKEN: ${{ github.token }} |
| 45 | + run: | |
| 46 | + if JSON="$( |
| 47 | + gh api \ |
| 48 | + -H "Accept: application/vnd.github+json" \ |
| 49 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 50 | + /repos/${{ github.repository }}/commits/${{ github.sha }}/pulls |
| 51 | + )" |
| 52 | + then |
| 53 | + # TODO: use PR info |
| 54 | + else |
| 55 | + # TODO: handle error getting PR info |
| 56 | + fi |
| 57 | +
|
| 58 | + - name: Send matrix message |
| 59 | + uses: lkiesow/matrix-notification@v1 |
| 60 | + with: |
| 61 | + # The Matrix home server to send the message to |
| 62 | + # Default: matrix.org |
| 63 | + server: matrix.org |
| 64 | + # TODO: token |
| 65 | + token: ... |
| 66 | + room: "!oOLohuKTgwSAvIxmdO:matrix.org" |
| 67 | + # The message to send (optional) |
| 68 | + message: Hello world |
| 69 | + # An HTML formatted version of the message to send |
| 70 | + formatted_message: Hello <b>World</b>! |
| 71 | + # Whether to install the `matrix-msg` exe |
| 72 | + # Only needed if you wish to send messages in other steps |
| 73 | + # We could use this to print a "summary" and a matrix message in the same step, for example |
| 74 | + tool: false |
| 75 | + |
| 76 | + - name: Print summary |
| 77 | + run: | |
| 78 | + # FIXME: copied from update workflow |
| 79 | + # TODO: adapt to this workflow |
| 80 | + num="${{ steps.pr.outputs.pull-request-number }}" |
| 81 | + pr_url="${{ steps.pr.outputs.pull-request-url }}" |
| 82 | + pr_branch="${{ steps.pr.outputs.pull-request-branch }}" |
| 83 | + head="${{ steps.pr.outputs.pull-request-head-sha }}" |
| 84 | + operation="${{ steps.pr.outputs.pull-request-operation }}" |
| 85 | +
|
| 86 | + # stdout |
| 87 | + echo "${head:0:6} pushed to ${pr_branch}" |
| 88 | + echo "${pr} was ${operation}." |
| 89 | +
|
| 90 | + # markdown summary |
| 91 | + echo "## ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY |
| 92 | + echo >> $GITHUB_STEP_SUMMARY |
| 93 | + echo "\`${head:0:6}\` pushed to \`${pr_branch}\`" >> $GITHUB_STEP_SUMMARY |
| 94 | + echo >> $GITHUB_STEP_SUMMARY |
| 95 | + echo "[#${num}](${pr_url}) was ${operation}." >> $GITHUB_STEP_SUMMARY |
| 96 | + echo >> $GITHUB_STEP_SUMMARY |
0 commit comments