Skip to content

Commit

Permalink
feat: allow use of consistent container tagging
Browse files Browse the repository at this point in the history
Adds ability to generate consistent container tag across workflows.
  • Loading branch information
wilsonjord committed May 24, 2024
1 parent 2877805 commit 3985c68
Show file tree
Hide file tree
Showing 2 changed files with 59 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 and timestamp
value:
${{ format('{0}-git{1}', steps.tags.outputs.timestamp, steps.tags.outputs.relevant-sha) }}

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
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
- [Markdown lint](#markdown-lint)
- [Copy to S3](#copy-to-s3)
- [Clean container versions](#clean-container-versions)
- [Composite Actions](#composite-actions)
- [Tagging](#tagging)
- [Other documentation](#other-documentation)
- [Dependabot and Actions workflow imports](#dependabot-and-actions-workflow-imports)
- [Versioning for container images](#versioning-for-container-images)
Expand Down Expand Up @@ -1090,6 +1092,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 3985c68

Please sign in to comment.