th: better image tags hopefully

pull/59/head
kouhai dev 2023-04-24 00:05:57 -07:00
parent e7ef14a4d7
commit f177325ba7
1 changed files with 17 additions and 4 deletions

View File

@ -5,6 +5,7 @@ variables:
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
environment: environment:
NAME: gitea.treehouse.systems/treehouse/mastodon NAME: gitea.treehouse.systems/treehouse/mastodon
DATE_COMMAND: export COMMIT_DATE=$(date -u -Idate -d @$(git show -s --format=%ct))
clone: clone:
git: git:
@ -29,13 +30,23 @@ pipeline:
build: build:
<<: *docker-step <<: *docker-step
commands: commands:
- eval $DATE_COMMAND
- export TAG=$${COMMIT_DATE}.$CI_COMMIT_SHA && echo $${TAG}
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME:latest - docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $NAME:latest
- docker tag $NAME:latest $NAME:$CI_COMMIT_SHA - docker tag $NAME:latest $NAME:$TAG
# idk what's actually persisted between steps
# /shrug this works, so,???
- echo $${TAG} > tags.txt
- echo latest >> tags.txt
tag-nightly: tag-nightly:
<<: *docker-step <<: *docker-step
commands: commands:
- docker tag $NAME:latest $NAME:$(date -Idate -u) - eval $DATE_COMMAND
- echo "$${COMMIT_DATE}"
- docker tag $NAME:latest $NAME:$COMMIT_DATE
- echo $COMMIT_DATE >> tags.txt
- cat tags.txt | xargs -n 1 -I% echo docker image push $NAME:%
# maybe we can use tags someday,,, # maybe we can use tags someday,,,
# tag-tag: # tag-tag:
@ -50,9 +61,11 @@ pipeline:
push: push:
<<: *docker-step <<: *docker-step
commands: commands:
- echo $REGISTRY_SECRET | docker login -u ariadne --password-stdin gitea.treehouse.systems - echo $REGISTRY_SECRET | docker login -u $REGISTRY_USER --password-stdin gitea.treehouse.systems
- docker image push --all-tags $NAME - cat tags.txt | xargs -n 1 -I% docker image push $NAME:%
when: when:
event: [push, tag] event: [push, tag]
branch: main branch: main
secrets: [REGISTRY_SECRET] secrets: [REGISTRY_SECRET]
environment:
REGISTRY_USER: ariadne