diff --git a/.github/workflows/check-misp-version.yml b/.github/workflows/check-misp-version.yml new file mode 100644 index 0000000..11405a8 --- /dev/null +++ b/.github/workflows/check-misp-version.yml @@ -0,0 +1,46 @@ +name: Check External Release +on: + schedule: + - cron: '0 0 * * 1' + workflow_dispatch: + +jobs: + check-release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get latest release + id: release + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + const { data: release } = await github.rest.repos.getLatestRelease({ + owner: 'MISP', + repo: 'MISP' + }); + return release.tag_name; + + - name: Compare with stored version + id: compare + run: | + LAST_VERSION=$(cat MISP_VERSION 2>/dev/null || echo "") + NEW_VERSION="${{ steps.release.outputs.result }}" + echo "last_version=$LAST_VERSION" >> $GITHUB_OUTPUT + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + if [ "$LAST_VERSION" != "$NEW_VERSION" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + echo "New MISP release detected: $NEW_VERSION" + echo "$NEW_VERSION" > MISP_VERSION + else + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Commit version file + if: steps.compare.outputs.changed == 'true' + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: 'Update MISP version to ${{ steps.compare.outputs.new_version }}' + file_pattern: MISP_VERSION \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 64b3517..2c8cedf 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,12 +5,6 @@ on: branches: [ main ] pull_request: branches: [ main ] - workflow_dispatch: - inputs: - misp_ref: - description: 'MISP branch or tag to build' - required: true - default: 'develop' env: REGISTRY_IMAGE: ghcr.io/nukib/misp @@ -33,8 +27,11 @@ jobs: uses: docker/setup-buildx-action@v4 - name: Fetch variables - run: for v in $(python3 .github/workflows/docker-version.py ${{ github.event.inputs.misp_ref }}); do echo $v >> $GITHUB_ENV; done - id: variables + run: | + MISP_VERSION=$(cat MISP_VERSION) + for v in $(python3 .github/workflows/docker-version.py ${MISP_VERSION}); + do echo $v >> $GITHUB_ENV; + done - name: Cache Docker layers uses: actions/cache@v6 diff --git a/MISP_VERSION b/MISP_VERSION new file mode 100644 index 0000000..c32614e --- /dev/null +++ b/MISP_VERSION @@ -0,0 +1 @@ +v2.5.50 \ No newline at end of file