diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..5bbea35 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,56 @@ +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/firefishbot + 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 '{"name": "'"${CURRENT_DATE}"'"}' \ + -d '{"prerelease": false}' \ + https://git.jo-dev.xyz/api/v1/repos/${GITEA_REPO}/releases diff --git a/views/layout.ejs b/views/layout.ejs index 7f40156..d0782a8 100644 --- a/views/layout.ejs +++ b/views/layout.ejs @@ -7,5 +7,6 @@

Jo's Express Template

+

Welcome to your new express app :)

\ No newline at end of file