Skip to content

Commit

Permalink
chore: update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed Mar 24, 2024
1 parent 20e83c0 commit 409d43e
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 44 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
name: auto-approve
on: pull_request_target

on:
pull_request_target:
types:
- opened
- synchronize
workflow_dispatch:
inputs:
pullRequestNumber:
description: Pull request number to auto-approve
required: false

jobs:
auto-approve:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.actor == 'dependabot[bot]' || github.ref == 'refs/heads/platform/update-version-meta-data' || github.event_name == 'workflow_dispatch'
steps:
- uses: hmarr/auto-approve-action@v3
with:
review-message: "Auto approved automated PR"
pull-request-number: ${{ github.event.inputs.pullRequestNumber }}
67 changes: 58 additions & 9 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,75 @@ name: release-drafter
on:
push:
branches:
- develop
- 'develop'
pull_request:
# Only following types are handled by the action, but one can default to all as well
types: [opened, reopened, synchronize]
types: [ opened, reopened, synchronize ]

permissions:
contents: read

jobs:
update-release-draft:
update-draft-release:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
id: release_drafter
with:
config-name: release-drafter-config.yml
disable-autolabeler: false
config-name: release-drafter-config.yml
disable-autolabeler: false
commitish: develop
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: 'develop'
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
- name: Configure dummy files
run: |
mv app/.travic-ci/google-services.json app/google-services.json
mv app/.travic-ci/secrets app/.config/secrets.properties
- name: Extract version
id: version
run: echo "${{ steps.release_drafter.outputs.resolved_version }}" > VERSION

- name: Calculate code
id: code
run: |
IFS='.' read -ra VER <<< "$(cat VERSION)"
MAJOR=$((VER[0] * 1000000000))
MINOR=$((VER[1] * 1000000))
PATCH=$((VER[2] * 1000))
CODE=$((MAJOR + MINOR + PATCH))
echo "version=$(cat VERSION)" > gradle/version.properties
echo "code=$CODE" >> gradle/version.properties
echo "name=v$(cat VERSION)" >> gradle/version.properties
- name: Show version
run: cat gradle/version.properties

- name: Generate version.json
run: ./gradlew generateVersions

- name: Push auto generated version file
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "automation: update version.properties"
branch: platform/update-version-meta-data
commit_options: '--no-verify --signoff'
file_pattern: 'gradle/version.properties app/.meta/version.json'
repository: .
commit_author: Author <[email protected]>
create_branch: true
push_options: '--force'
skip_fetch: true
69 changes: 35 additions & 34 deletions .github/workflows/version-updater.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
name: version-updater

on:
repository_dispatch:
types: [version-updater]
push:
branches:
- 'platform/update-version-meta-data'

workflow_dispatch:
inputs:
branchName:
description: Pull request against branch
default: 'platform/update-version-meta-data'
type: choice
options:
- 'platform/update-version-meta-data'
required: true


permissions:
contents: write
pull-requests: write

jobs:
version-updater:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Extract version
id: version
run: echo "${GITHUB_REF#refs/tags/}" > VERSION

- name: Calculate version code
id: code
run: |
IFS='.' read -ra VER <<< "$(cat VERSION)"
MAJOR=$((VER[0] * 1000000000))
MINOR=$((VER[1] * 10000))
PATCH=${VER[2]}
CODE=$((MAJOR + MINOR + PATCH))
echo "version=$(cat VERSION)" > gradle/version.properties
echo "code=$CODE" >> gradle/version.properties
echo "name=v$(cat VERSION)" >> gradle/version.properties
- name: Show release info
run: cat gradle/version.properties
uses: actions/checkout@v4
with:
ref: develop

- name: Commit version.properties
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add gradle/version.properties
git commit -m "Bump version to $(cat VERSION)"
- name: Push changes
uses: ad-m/github-push-action@master
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: develop
directory: .
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "automation: update version.properties"
author: "Author <[email protected]>"
title: "platform: automated version update"
body: |
This PR was automatically generated to update version.properties.
branch: ${{ github.event.inputs.branchName }}
base: develop
labels: "skip-changelog"
assignees: "wax911"
reviewers: "wax911"

0 comments on commit 409d43e

Please sign in to comment.