diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index eacc059e..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,90 +0,0 @@ -name: Docker - -on: - push: - # Publish `master` as Docker `latest` image. - branches: [ main ] - -env: - IMAGE_NAME: capt-mifune - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - env: - CI: false - - uses: actions/setup-java@v2 - with: - java-version: '17' - distribution: 'adopt' - - uses: actions/cache@v2 - with: - path: '**/node_modules' - key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} - - name: yarn install - run: yarn --cwd ui install - - name: yarn generate api - run: yarn --cwd ui generate-backend-api - - name: yarn build - run: yarn --cwd ui build - env: - CI: false - - name: run maven - run: mvn -f server/pom.xml clean install - - - -# -# # Push image to GitHub Packages. -# # See also https://docs.docker.com/docker-hub/builds/ -# push: -# # Ensure test job passes before pushing image. -# # needs: test -# -# runs-on: ubuntu-latest -# if: github.event_name == 'push' -# -# permissions: -# contents: read -# packages: write -# -# steps: -# - uses: actions/checkout@v2 -# -# - name: Build image -# run: docker build . --file Dockerfile --tag $IMAGE_NAME -# -# - name: Login to harbor -# uses: docker/login-action@v1 -# with: -# registry: harbor.prodyna.com -# username: ${{ secrets.HARBOR_USER }} -# password: ${{ secrets.HARBOR_PASSWORD }} -# -# - name: Push image -# run: | -# IMAGE_ID=harbor.prodyna.com/capt-mifune/$IMAGE_NAME -# -# # Change all uppercase to lowercase -# IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') -# -# # Strip git ref prefix from version -# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') -# -# # Strip "v" prefix from tag name -# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') -# -# # Use Docker `latest` tag convention -# [ "$VERSION" == "master" ] && VERSION=latest -# -# echo IMAGE_ID=$IMAGE_ID -# echo VERSION=$VERSION -# -# docker tag $IMAGE_NAME $IMAGE_ID:$VERSION -# docker push $IMAGE_ID:$VERSION diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..e27e1f02 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: Docker + +on: + release: + types: [published] + +env: + IMAGE_NAME: capt-mifune + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16' + env: + CI: false + - uses: actions/setup-java@v2 + with: + java-version: '17' + distribution: 'adopt' + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - name: yarn install + run: yarn --cwd ui install + - name: yarn generate api + run: yarn --cwd ui generate-backend-api + - name: yarn build + run: yarn --cwd ui build + env: + CI: false + - name: run maven + run: mvn -f server/pom.xml clean install + + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: | + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}