2022-07-28 17:46:12 +00:00
|
|
|
name: Tipi CI
|
|
|
|
on:
|
2023-06-20 17:34:42 +00:00
|
|
|
pull_request:
|
2023-06-21 19:11:50 +00:00
|
|
|
types: [opened, synchronize, reopened, ready_for_review]
|
2023-06-20 20:52:42 +00:00
|
|
|
|
2022-07-28 17:46:12 +00:00
|
|
|
jobs:
|
2023-06-20 22:50:47 +00:00
|
|
|
get-last-commit-message:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Get last commit message
|
|
|
|
id: get-last-commit-message
|
|
|
|
run: |
|
|
|
|
echo "last_commit_message=$(git log -1 --pretty=%B)" >> $GITHUB_OUTPUT
|
|
|
|
|
2023-06-21 19:11:50 +00:00
|
|
|
update-config:
|
|
|
|
needs: get-last-commit-message
|
2023-06-21 20:17:17 +00:00
|
|
|
if: github.event_name == 'pull_request' && !contains(${{ needs.get-last-commit-message.outputs.last_commit_message }}, '[ready]') && contains(github.ref_name, 'renovate')
|
2023-06-21 19:11:50 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-06-21 21:10:24 +00:00
|
|
|
token: ${{ secrets.PERSONAL_TOKEN }}
|
2023-06-21 19:11:50 +00:00
|
|
|
|
2023-06-21 20:36:40 +00:00
|
|
|
- name: Get changed files
|
|
|
|
uses: jitterbit/get-changed-files@v1
|
|
|
|
id: files
|
2023-06-21 19:11:50 +00:00
|
|
|
|
2023-06-21 20:36:40 +00:00
|
|
|
- name: Apply config update
|
2023-06-21 19:11:50 +00:00
|
|
|
run: |
|
2023-06-21 20:36:40 +00:00
|
|
|
for changed_file in ${{ steps.files.outputs.all }}; do
|
2023-06-21 20:42:32 +00:00
|
|
|
echo "Changed file: $changed_file" # example: apps/jackett/docker-compose.yml
|
|
|
|
if [[ $changed_file == *"docker-compose.yml"* ]]; then
|
|
|
|
app_name=$(echo $changed_file | cut -d'/' -f 2)
|
2023-06-21 20:40:08 +00:00
|
|
|
echo "App name: $app_name"
|
2023-06-21 19:11:50 +00:00
|
|
|
./.github/workflows/renovate-app-version.sh $app_name
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2023-06-21 20:17:17 +00:00
|
|
|
- name: Commit and push changes
|
2023-06-21 20:51:42 +00:00
|
|
|
uses: EndBug/add-and-commit@v9
|
|
|
|
with:
|
|
|
|
author_name: Tipi CI
|
|
|
|
author_email: ci@runtipi.io
|
|
|
|
message: "Update app version [ready]"
|
|
|
|
commit: --no-verify
|
2023-06-21 20:59:39 +00:00
|
|
|
push: origin HEAD:${{ github.head_ref }}
|
2023-06-21 20:17:17 +00:00
|
|
|
|
2022-07-28 17:46:12 +00:00
|
|
|
ci:
|
2023-06-21 21:21:23 +00:00
|
|
|
needs:
|
|
|
|
- update-config
|
|
|
|
- get-last-commit-message
|
|
|
|
if: contains(${{ needs.get-last-commit-message.outputs.last_commit_message }}, '[ready]') || !contains(github.ref_name, 'renovate')
|
2022-07-28 17:46:12 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
2023-06-21 21:27:21 +00:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.PERSONAL_TOKEN }}
|
2022-07-28 17:46:12 +00:00
|
|
|
|
|
|
|
- name: Install Node.js
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
2023-06-21 19:11:50 +00:00
|
|
|
node-version: 18
|
2022-07-28 17:46:12 +00:00
|
|
|
|
|
|
|
- uses: pnpm/action-setup@v2.0.1
|
|
|
|
name: Install pnpm
|
|
|
|
id: pnpm-install
|
|
|
|
with:
|
2023-06-21 19:11:50 +00:00
|
|
|
version: 8
|
2022-07-28 17:46:12 +00:00
|
|
|
run_install: false
|
|
|
|
|
|
|
|
- name: Get pnpm store directory
|
|
|
|
id: pnpm-cache
|
|
|
|
run: |
|
2023-06-20 20:52:42 +00:00
|
|
|
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
|
2022-07-28 17:46:12 +00:00
|
|
|
|
|
|
|
- uses: actions/cache@v3
|
|
|
|
name: Setup pnpm cache
|
|
|
|
with:
|
|
|
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm install
|
|
|
|
|
|
|
|
- name: Run global tests
|
2022-08-24 09:37:18 +00:00
|
|
|
run: pnpm test
|
|
|
|
|
|
|
|
- name: Run linter
|
2023-06-20 17:34:42 +00:00
|
|
|
run: pnpm run lint
|
2023-06-20 20:52:42 +00:00
|
|
|
|
|
|
|
- name: Check bumped version
|
|
|
|
id: check-bumped-version
|
|
|
|
uses: actions/github-script@v4
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
const semver = require('semver')
|
|
|
|
const { data } = await github.pulls.listFiles({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
pull_number: context.issue.number
|
|
|
|
});
|
|
|
|
|
|
|
|
const modifiedFiles = data.map(file => file.filename);
|
|
|
|
const filesInAppsFolder = modifiedFiles.filter(file => file.includes('apps/'))
|
|
|
|
|
|
|
|
if (filesInAppsFolder.length < modifiedFiles.length) {
|
|
|
|
console.log('Not all files are in apps folder, skipping automerge')
|
|
|
|
core.setOutput('major_bump', 'true')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const configs = modifiedFiles.filter(file => file.includes('config.json'))
|
|
|
|
let majorBump = 'false'
|
|
|
|
|
|
|
|
for (const configFile of configs) {
|
|
|
|
const baseContent = await github.repos.getContent({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
path: configFile,
|
|
|
|
ref: context.payload.pull_request.base.ref
|
|
|
|
});
|
|
|
|
const baseConfig = JSON.parse(Buffer.from(baseContent.data.content, 'base64').toString('utf-8'))
|
|
|
|
|
|
|
|
const currentContent = await github.repos.getContent({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
path: configFile,
|
|
|
|
ref: context.payload.pull_request.head.ref
|
|
|
|
});
|
|
|
|
const currentConfig = JSON.parse(Buffer.from(currentContent.data.content, 'base64').toString('utf-8'))
|
|
|
|
|
|
|
|
const baseVersion = semver.coerce(baseConfig.version)
|
|
|
|
const currentVersion = semver.coerce(currentConfig.version)
|
|
|
|
|
|
|
|
if (currentVersion?.major > baseVersion?.major) {
|
|
|
|
console.log('Major bump detected, skipping automerge')
|
|
|
|
majorBump = 'true'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
core.setOutput('major_bump', majorBump)
|
|
|
|
|
|
|
|
- name: Label this PR as "automerge" if major_bump is false
|
|
|
|
if: steps.check-bumped-version.outputs.major_bump == 'false'
|
|
|
|
uses: actions/github-script@v4
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
script: |
|
|
|
|
github.issues.addLabels({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
labels: ["automerge"]
|
|
|
|
})
|