Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lolgear/1ab91e7374feb811ab3ceb51505f7f29 to your computer and use it in GitHub Desktop.
Save lolgear/1ab91e7374feb811ab3ceb51505f7f29 to your computer and use it in GitHub Desktop.
This is an example workflow that shows how to keep build number in a repository and keep it up-to-date. This action is fired on push to specified branch.
name: Awesome App
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ master ]
# pull_request:
# branches: [ develop ]
jobs:
name: Build master
runs-on: calculator
steps:
# steps fast overview
# 1. We checkout on a commit
# 2. Increment build number in a file under git tracking.
# 3. Build an artifact
# 4. Upload an artifact to github.
# 5. Commit updated build number.
# 6. Push a commit with a file with new build number to a repository.
# Checkout commit
- name: Checkout
uses: actions/checkout
# Increment build number
- name: Increment build number
run: |
NUMBER=./scripts/get_build_number.sh
NUMBER=$(NUMBER+1)
write_build_number($NUMBER)
# Build an artifact
- name: Build artifact
run: sh ./scripts/build_release.sh
# Upload artifact
- name: Upload artifact to git
uses: actions/upload-artifact
with: path-to-build
# Commit updated build number
- name: Additional commit of build number file
uses: actions/commit
message: version number $(NUMBER) # read from manifest? ok
path: BUILD_NUMBER_FILE
# Push updated build number
- name: Push updated build number to repository
run: git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment