Automate Gitea Docker image publishing
Build and publish Docker image / build-and-publish (push) Failing after 2s
Build and publish Docker image / build-and-publish (push) Failing after 2s
This commit is contained in:
1 parent
2d61d80550
commit
1026b1ba33
3 files changed
+64
No files matched your search
@@ -0,0 +1,49 @@
|
||||
name: Build and publish Docker image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: builtin:checkout
|
||||
|
||||
- name: Log in to Gitea Container Registry
|
||||
env:
|
||||
REGISTRY_USER: ${{ gitea.actor }}
|
||||
REGISTRY_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: printf '%s' "$REGISTRY_TOKEN" | docker login git.anchorhost.eu --username "$REGISTRY_USER" --password-stdin
|
||||
|
||||
- name: Build and tag image
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
image='git.anchorhost.eu/anchorhost.eu/anchorhost-frontend'
|
||||
short_sha="$(printf '%.12s' "$COMMIT_SHA")"
|
||||
docker build \
|
||||
--label "org.opencontainers.image.revision=$COMMIT_SHA" \
|
||||
--tag "$image:main-$short_sha" \
|
||||
--tag "$image:main-latest" \
|
||||
.
|
||||
|
||||
- name: Push image tags
|
||||
env:
|
||||
COMMIT_SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
image='git.anchorhost.eu/anchorhost.eu/anchorhost-frontend'
|
||||
short_sha="$(printf '%.12s' "$COMMIT_SHA")"
|
||||
docker push "$image:main-$short_sha"
|
||||
docker push "$image:main-latest"
|
||||
|
||||
- name: Log out from Gitea Container Registry
|
||||
if: always()
|
||||
run: docker logout git.anchorhost.eu
|
||||
Reference in new issue
Block a user