| 1 | docker: |
| 2 | name: Build & Push Image |
| 3 | needs: build |
| 4 | if: github.event_name == 'push' |
| 5 | runs-on: ubuntu-latest |
| 6 | |
| 7 | steps: |
| 8 | - uses: actions/checkout@v4 |
| 9 | |
| 10 | - name: Log in to Gitea registry |
| 11 | uses: docker/login-action@v3 |
| 12 | with: |
| 13 | registry: git.thc420.dev |
| 14 | username: ${{ github.actor }} |
| 15 | password: ${{ secrets.CI_TOK }} |
| 16 | |
| 17 | - name: Set up Docker Buildx |
| 18 | uses: docker/setup-buildx-action@v3 |
| 19 | |
| 20 | - name: Determine image tags |
| 21 | id: imgtags |
| 22 | run: | |
| 23 | if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
| 24 | { |
| 25 | echo "tags<<TAGS_EOF" |
| 26 | echo "git.thc420.dev/ouch/relay:latest" |
| 27 | echo "git.thc420.dev/ouch/relay:${GITHUB_REF#refs/tags/}" |
| 28 | echo "TAGS_EOF" |
| 29 | } >> "$GITHUB_OUTPUT" |
| 30 | else |
| 31 | echo "tags=git.thc420.dev/ouch/relay:latest" >> "$GITHUB_OUTPUT" |
| 32 | fi |
| 33 | |
| 34 | - name: Determine image build commit |
| 35 | id: buildmeta |
| 36 | run: | |
| 37 | if [[ "$GITHUB_REF" == refs/heads/master ]]; then |
| 38 | echo "commit=$GITHUB_SHA" >> "$GITHUB_OUTPUT" |
| 39 | else |
| 40 | echo "commit=" >> "$GITHUB_OUTPUT" |
| 41 | fi |
| 42 | |
| 43 | - name: Build and push |
| 44 | uses: docker/build-push-action@v6 |
| 45 | with: |
| 46 | context: . |
| 47 | push: true |
| 48 | tags: ${{ steps.imgtags.outputs.tags }} |
| 49 | build-args: | |
| 50 | RELAY_BUILD_COMMIT=${{ steps.buildmeta.outputs.commit }} |
blackbeard420 / docker.yaml
Last active 1 month ago