ExpressTemplate/.gitea/workflows/build.yml
Jo 2e99463306
All checks were successful
Build and push Docker image / build-and-push (push) Successful in 44s
fix: update release section in build process (for real, hopefully)
2023-11-26 01:37:16 +01:00

55 lines
2.1 KiB
YAML

name: Build and push Docker image
on:
push:
branches:
- main
# Secrets you have to set up for this to work:
# REPO_TOKEN: A gitea access token for the repo
# REGISTRY_USERNAME/PASSWORD: The username and password for the docker registry of choice
env:
DOCKER_REPO: git.jo-dev.xyz/jo
DOCKER_TAG: latest
GITEA_REPO: jo/expresstemplate
GITEA_TOKEN: ${{ secrets.REPO_TOKEN }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Set current date and time
run: echo "CURRENT_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
- name: Install Docker
run: |
apt-get update
apt-get -y install apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get -y install docker-ce docker-ce-cli containerd.io
- name: Login to Docker registry
uses: docker/login-action@v1
with:
registry: git.jo-dev.xyz
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build Docker image
run: |
docker build -t ${DOCKER_REPO}:${DOCKER_TAG} .
docker tag ${DOCKER_REPO}:${DOCKER_TAG} git.jo-dev.xyz/${GITEA_REPO}:${DOCKER_TAG}
- name: Push Docker image to Gitea package
run: |
docker push git.jo-dev.xyz/${GITEA_REPO}:${DOCKER_TAG}
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"tag_name": "'"${DOCKER_TAG}"'"}' \
-d '{"description": "'"${CURRENT_DATE}"'"}' \
https://git.jo-dev.xyz/api/v1/repos/${GITEA_REPO}/releases