manala / manala

Let your projects' plumbings up to date
https://manala.github.io/manala/
MIT License
17 stars 2 forks source link

Provide a Github action/workflow to automatically manala up on .manala changes #23

Open ogizanagi opened 4 years ago

ogizanagi commented 4 years ago

So we won't even miss an update

nervo commented 4 years ago

Wow, with a ready-to-merge pull request ?

With goreleaser, we could build a docker image, but before your issue, i've never seen a good reason to do it :)

ogizanagi commented 4 years ago

Very basically introduced on-per-project basis with the following patch:

diff --git a/.github/actions/manala-up/action.yml b/.github/actions/manala-up/action.yml
new file mode 100644
index 000000000..3edd1e57b
--- /dev/null
+++ b/.github/actions/manala-up/action.yml
@@ -0,0 +1,16 @@
+name: Manala update
+description: 'Automatically run manala update on .manala.yml changes in case the developper forgot it'
+
+runs:
+  using: composite
+  steps:
+
+    - name: Install Manala binary
+      shell: bash
+      run: |
+        curl -sfL https://raw.githubusercontent.com/manala/manala/master/godownloader.sh | sh
+        echo "./bin/" >> $GITHUB_PATH
+
+    - name: Run Manala update
+      shell: bash
+      run: manala update
diff --git a/.github/workflows/manala-up.yml b/.github/workflows/manala-up.yml
new file mode 100644
index 000000000..84ebfe2ae
--- /dev/null
+++ b/.github/workflows/manala-up.yml
@@ -0,0 +1,32 @@
+name: Manala up
+on:
+  push:
+    branches:
+      - master
+    paths:
+      - '.manala.yaml'
+  pull_request:
+    paths:
+      - '.manala.yaml'
+
+jobs:
+  up:
+    runs-on: ubuntu-latest
+    steps:
+
+      - name: Checkout head
+        uses: actions/checkout@v2
+
+      - name: Setup & Run Manala update
+        uses: ./.github/actions/manala-up
+
+      # https://github.com/EndBug/add-and-commit
+      - name: Commit & push changes
+        uses: EndBug/add-and-commit@v4
+        with:
+          author_name: GitHub Actions Bot
+          author_email: actions@github.com
+          message: '[AUTO] By Github Actions: Run manala update'
+          add: ".manala/"
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

We could provide an official action for Manala setup and add a way to generate the worflow automatically with the Manala CLI.

nervo commented 4 years ago

what about having a .manala/github/workflow/update.yaml available through the recipe ?

ogizanagi commented 4 years ago

Sure, but the resulting path where to generate the workflow file has to be in the .github/workflow directory, so out of the .manala dir. I don't think there is any alternative available today.

ogizanagi commented 4 years ago

Also, something interesting is Organization Workflows templates: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/sharing-workflows-with-your-organization