Skip to content

Commit

Permalink
Merge pull request #1 from riege/BUILD-52_Provide_GitHub_Action_to_de…
Browse files Browse the repository at this point in the history
…termine_container_image_tag

BUILD-52 Provide GitHub action to determine the version
  • Loading branch information
d-ast authored May 4, 2021
2 parents fb2ceae + 89d735e commit f025368
Show file tree
Hide file tree
Showing 24 changed files with 1,702 additions and 2 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/testAction.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
action_outputs:
runs-on: ubuntu-latest
name: Test action
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test
- uses: ./
id: version
- run: |
export VERSION="${{ steps.version.outputs.version }}"
echo "$VERSION must match .+-.+-.+"
bash -c '[[ $VERSION =~ .+-.+-.+ ]]'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea

node_modules/*

!node_modules/@actions
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# action-container-image-tag
A GitHub action to determine a container image tag
# action-version
A GitHub action to determine the version for build artifacts.

## Outputs
version: The version string

| CI/CD Build | Version |
| ----------- | ----------- |
| Git tag x.y.z on master branch (a prefixed "v" is okay, too) | X.Y.Z, X.Y, X, vX.Y.Z ... |
| Untagged main commit | main-\<runnumber\>-\<sha\> |
| Pull request | pr-\<prnumber\>-\<runnumber\>-\<sha\>

## Example Usage
```
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
branches: [ main ]
types: [published]
jobs:
action_outputs:
runs-on: ubuntu-latest
name: Echo action's outputs
steps:
- id: version
uses: riege/[email protected]
- run: |
echo Version: ${{ steps.version.outputs.version }}
echo Image tag: "${{ secrets.ACR_LOGIN_SERVER }}/my-container:${{ steps.version.outputs.version }}"
```
10 changes: 10 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: 'Version'
description: 'Determine the version for the build artifacts'

outputs:
version:
description: "The version string"

runs:
using: "node12"
main: "index.js"
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const core = require('@actions/core');
const getVersion = require('./version');

try {
const version = getVersion.get(process.env.GITHUB_REF, process.env.GITHUB_RUN_NUMBER, process.env.GITHUB_SHA);
core.setOutput("version", version);
} catch (error) {
core.setFailed(error.message);
}
9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

202 changes: 202 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f025368

Please sign in to comment.