chore: add gitea action on push
This commit is contained in:
		
							parent
							
								
									a19e1415f1
								
							
						
					
					
						commit
						e514396d91
					
				
					 2 changed files with 57 additions and 0 deletions
				
			
		
							
								
								
									
										56
									
								
								.gitea/workflows/build.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								.gitea/workflows/build.yml
									
										
									
									
									
										Normal file
									
								
							|  | @ -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     | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue