30 lines
1020 B
YAML
30 lines
1020 B
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: runner
|
|
container: docker:24-git
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
# Configure git to use the token
|
|
git config --global credential.helper store
|
|
echo "https://${{ gitea.actor }}:${{ secrets.GITEA_TOKEN }}@${{ gitea.server_url }}" > ~/.git-credentials
|
|
|
|
# Clone without credentials in URL
|
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
|
git checkout ${{ gitea.sha }}
|
|
|
|
# Clean up credentials
|
|
rm ~/.git-credentials
|
|
|
|
- name: Build and push
|
|
run: |
|
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login ${{ gitea.server_url }} -u ${{ gitea.actor }} --password-stdin
|
|
docker build -t ${{ gitea.server_url }}/${{ gitea.repository_owner }}/hello-gitea:latest .
|
|
docker push ${{ gitea.server_url }}/${{ gitea.repository_owner }}/hello-gitea:latest
|