diff --git a/.github/actions/tagging/action.yml b/.github/actions/tagging/action.yml new file mode 100644 index 0000000..f505b83 --- /dev/null +++ b/.github/actions/tagging/action.yml @@ -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 diff --git a/README.md b/README.md index 8a9ebeb..283a3a3 100644 --- a/README.md +++ b/README.md @@ -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