Skip to content

Commit

Permalink
feat: allow use of consistent container tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonjord committed May 16, 2024
1 parent 6add3d2 commit 27bc9b1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/actions/tagging/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Tagging
description: Consistent and unique container tagging, suitable for immutable tagging
outputs:
relevant-sha:
description: |
Short commit sha based on last commit of pull request, or the last merge commit
value: ${{ steps.tags.outputs.relevant-sha }}
timestamp:
description: |
UTC time of when this action was run
value: ${{ steps.tags.outputs.timestamp }}
tag:
description: |
Recommended container tag, using commit sha, timestamp, and build id
value:
${{ format('{0}-{1}-{2}', steps.tags.outputs.relevant-sha, steps.tags.outputs.timestamp, github.run_id) }}

runs:
using: "composite"
steps:
- name: Generate tags
id: tags
env:
RELEVANT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
shell: bash
run: |
echo "relevant-sha=$(git rev-parse --short $RELEVANT_SHA)" >> $GITHUB_OUTPUT
echo "timestamp=$(date -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,35 @@ jobs:
number-kept: 7
```

## Composite Actions

### Tagging

STATUS: stable

Generic container tagging.

Generally will be used in the reusable workflows, but if one needed to use the action directly:

```yaml
on: [push]
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: steps.tagging.outputs.tag
steps:
- uses: actions/checkout@v4
- id: tagging
uses: GeoNet/Actions/.github/actions/tagging@main
build:
needs: prepare
uses: GeoNet/Actions/.github/workflows/reusable-docker-build.yml@main
with:
tag: ${{ needs.prepare.outputs.tag }}
```

## Other documentation

### Dependabot and Actions workflow imports
Expand Down

0 comments on commit 27bc9b1

Please sign in to comment.