diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12483e3..e2fb179 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: env: IMAGE_NAME: action + REGISTRY: ghcr.io jobs: test-image: @@ -53,7 +54,8 @@ jobs: tag: if: github.event_name == 'push' && needs.test-versions.outputs.version != '' - needs: [test-image, test-versions] + # needs: [test-image, test-versions] + needs: [test-versions] runs-on: ubuntu-latest permissions: contents: write @@ -71,34 +73,59 @@ jobs: env: VERSION: ${{ needs.test-versions.outputs.version }} GH_TOKEN: ${{ github.token }} + publish: runs-on: ubuntu-latest permissions: packages: write - needs: [tag, test-versions] - if: needs.tag.outputs.tagExists == 'false' + # !Undo this + needs: [test-versions] steps: - - uses: actions/checkout@v3 - - name: Build image - run: docker build . --file Dockerfile --label "version=$TAG" --tag $IMAGE_NAME - env: - TAG: v${{ needs.test-versions.outputs.version }} - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$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 - [[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//') - # Use Docker `latest` tag convention - [ "$VERSION" == "main" ] && VERSION=latest - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.IMAGE_NAME }} + - run: echo "Tags are $tags and labels are $labels" env: - TAG: v${{ needs.test-versions.outputs.version }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - uses: actions/checkout@v3 + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # - uses: actions/checkout@v3 + # - name: Build image + # run: docker build . --file Dockerfile --label "version=$TAG" --tag $IMAGE_NAME + # env: + # TAG: v${{ needs.test-versions.outputs.version }} + # - name: Log into registry + # run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin + # - name: Push image + # run: | + # IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$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 + # [[ ! -z $TAG ]] && VERSION=$(echo $TAG | sed -e 's/^v//') + # # Use Docker `latest` tag convention + # [ "$VERSION" == "main" ] && VERSION=latest + # echo IMAGE_ID=$IMAGE_ID + # echo VERSION=$VERSION + # docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + # docker push $IMAGE_ID:$VERSION + # env: + # TAG: v${{ needs.test-versions.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 52ee472..31e44ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ RUN yarn run build FROM node:18-slim +LABEL mantainer="Javier Bullrich " + COPY --from=Builder /action/dist /action ENTRYPOINT ["node", "/action/index.js"]