-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (44 loc) · 1.32 KB
/
javascript.yml
File metadata and controls
47 lines (44 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Build
on:
push:
branches:
- master
pull_request:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine tag
id: tag-determiner
env:
PR_NUM: ${{ github.event.pull_request.number }}
run: |
SECONDS_IN_YEAR=$(($(date +%s) - $(date +%s --date="$(date +%Y)-01-01 00:00:00 UTC")))
# Seconds in hex padded to 7 digits
SECONDS_HEX=$(printf "%.7x\n" ${SECONDS_IN_YEAR})
# Replace slashes in refname since not supported in image tags
REF_NAME=$(echo ${GITHUB_REF_NAME} | sed -e 's~/~-~g')
if [ -n "${PR_NUM}" ]
then
REF_NAME=pr-${PR_NUM}
fi
echo "tag-name=${REF_NAME}-$(date +%Y)-${SECONDS_HEX}" >> $GITHUB_OUTPUT
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag-determiner.outputs.tag-name }}