fix: owner name in ghcr.io #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: [push, pull_request] | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
backend: | |
name: Backend | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 21 | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v3 | |
- name: Build | |
run: gradle build | |
- name: Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rm-monitor | |
path: ./build/libs | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
needs: [ backend ] | |
outputs: | |
new_version: ${{ steps.should_push.outputs.new_version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Fetch Previous version | |
id: get-previous-tag | |
uses: actions-ecosystem/[email protected] | |
- name: mkdir | |
run: | | |
mkdir dist | |
- name: Download Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: rm-monitor | |
path: ./dist | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: yarn global add semantic-release @semantic-release/changelog && semantic-release | |
- name: Fetch Current version | |
id: get-current-tag | |
uses: actions-ecosystem/[email protected] | |
- name: Output New Version | |
id: should_push | |
run: | | |
old_version=${{steps.get-previous-tag.outputs.tag}} | |
new_version=${{steps.get-current-tag.outputs.tag }} | |
if [ "$old_version" != "$new_version" ]; then | |
echo "new_version=$new_version" >> $GITHUB_OUTPUT | |
else | |
echo "new_version=" >> $GITHUB_OUTPUT | |
fi | |
docker: | |
runs-on: ubuntu-latest | |
needs: [ release ] | |
if: github.event_name == 'push' && needs.release.outputs.new_version != '' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Login to GHCR | |
if: github.event_name != 'pull_request' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Push | |
uses: docker/build-push-action@v5 | |
if: github.event_name == 'push' | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64 | |
tags: | | |
scutrobot/rm-monitor:latest | |
scutrobot/rm-monitor:${{ needs.release.outputs.new_version }} | |
ghcr.io/scutrobotlab/rm-monitor:latest | |
ghcr.io/scutrobotlab/rm-monitor:${{ needs.release.outputs.new_version }} | |
build-args: | | |
VERSION=${{ needs.release.outputs.new_version }} | |
labels: | | |
org.opencontainers.image.source=https://github.com/scutrobot/rm-monitor | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} | |
org.opencontainers.image.version=${{ needs.release.outputs.new_version }} | |
org.opencontainers.image.title=rm-monitor ${{ needs.release.outputs.new_version }} | |
org.opencontainers.image.description="robomaster monitor" | |
org.opencontainers.image.licenses=AGPL-3.0 | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |