diff --git a/.github/workflows/platform-ci.yml b/.github/workflows/platform-ci.yml index c9623b9bb5..170ebb66c9 100644 --- a/.github/workflows/platform-ci.yml +++ b/.github/workflows/platform-ci.yml @@ -21,6 +21,15 @@ on: - '**/argoDeploy.json' - '**/cloudDeploy.json' branches: [ master, dev ] + pull_request: + paths-ignore: + #- '.github/**' # enable before merge + - 'docs/**' + - 'build/**' + - 'README.md' + - 'LICENSE' + - '**/argoDeploy.json' + - '**/cloudDeploy.json' jobs: ci: @@ -210,7 +219,7 @@ jobs: with: artifactUrl: ${{ steps.artifactUrl.outputs.DOCKER_URL }} repoOrg: ${{ github.repository_owner }} - downloadComment: 'Artifact URL:' + downloadComment: 'Image tag:' - name: Publish Github Release if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }} @@ -311,4 +320,4 @@ jobs: jiraKeys: ${{ needs.ci.outputs.jira-keys }} argoServer: 'argo.virtocommerce.cloud' matrix: '{"include":${{ needs.ci.outputs.matrix }}}' - secrets: inherit + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/pr-ci.yml b/.github/workflows/pr-ci.yml index c5e48c5053..59d45df5e0 100644 --- a/.github/workflows/pr-ci.yml +++ b/.github/workflows/pr-ci.yml @@ -4,16 +4,16 @@ name: Platform PR build on: workflow_dispatch: - pull_request: - branches: [ master, dev ] - paths-ignore: - - '.github/**' - - 'docs/**' - - 'build/**' - - 'README.md' - - 'LICENSE' - - '**/argoDeploy.json' - - '**/cloudDeploy.json' + # pull_request: + # branches: [ master, dev ] + # paths-ignore: + # #- '.github/**' + # - 'docs/**' + # - 'build/**' + # - 'README.md' + # - 'LICENSE' + # - '**/argoDeploy.json' + # - '**/cloudDeploy.json' jobs: test: @@ -28,17 +28,92 @@ jobs: secrets: envPAT: ${{ secrets.REPO_TOKEN }} + publish: + runs-on: ubuntu-latest + needs: + build + env: + DOCKER_TAR: ${{ needs.build.outputs.dockerTar }} + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + PACKAGE_SERVER: 'ghcr.io' + PUBLISH_TO_DOCKER: false + UPDATE_LATEST_TAG: false + steps: + - name: Get Docker image from cache + uses: actions/cache@v4 + id: restore-build + with: + key: ${{ needs.build.outputs.dockerFullKey }} + restore-keys: '${{ needs.build.outputs.dockerShortKey }}-' + path: | + ${{ env.DOCKER_TAR }} + + - name: Check cache status # Warn workflow if fullKey not present + if: steps.restore-build.outputs.cache-hit != 'true' + run: | + echo -e "\033[33mWarning: Cache not found for input keys: ${{ needs.build.outputs.dockerFullKey }}. The cache may have been restored from alternative key '${{ needs.build.outputs.dockerShortKey }}-'" + + - name: Load Docker image + id: load-docker + uses: VirtoCommerce/vc-github-actions/docker-load-image@master + with: + dockerTar: ${{ env.DOCKER_TAR }} + + # - name: Docker Login + # uses: docker/login-action@v3 + # with: + # registry: ${{ env.PACKAGE_SERVER }} + # username: $GITHUB_ACTOR + # password: ${{ env.GITHUB_TOKEN }} + + # - name: Push to GH + # run: | + # docker login --username $GITHUB_ACTOR --password ${{ env.GITHUB_TOKEN }} ${{ env.PACKAGE_SERVER }} + # docker push ${{ steps.load-docker.outputs.image }}:${{ steps.load-docker.outputs.tag }} + + - name: Publish Docker Image + uses: VirtoCommerce/vc-github-actions/publish-docker-image@master + with: + image: ${{ steps.load-docker.outputs.image }} + tag: ${{ steps.load-docker.outputs.tag }} + docker_user: ${{ secrets.DOCKER_USERNAME }} + docker_token: ${{ env.GITHUB_TOKEN }} # ${{ secrets.DOCKER_TOKEN }} + docker_hub: ${{ env.PUBLISH_TO_DOCKER }} + update_latest: ${{ env.UPDATE_LATEST_TAG }} + + + # uses: VirtoCommerce/.github/.github/workflows/publish-docker.yml@v3.800.7 + # with: + # fullKey: ${{ needs.build.outputs.dockerFullKey }} + # shortKey: '${{ needs.build.outputs.dockerShortKey }}-' + # dockerTar: ${{ needs.build.outputs.dockerTar }} + # publishToDocker: true + # secrets: + # envPAT: ${{ secrets.REPO_TOKEN }} + # # dockerUser: $GITHUB_ACTOR + # # dockerToken: ${{ secrets.REPO_TOKEN }} + # dockerUser: ${{ secrets.DOCKER_USERNAME }} + # dockerToken: ${{ secrets.DOCKER_TOKEN }} + publish-tag: - needs: build + needs: publish runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} + ARTIFACT_NAME: 'platform' steps: + # - name: Get cache key + # uses: VirtoCommerce/vc-github-actions/cache-get-key@master + # id: cache-key + # with: + # runnerOs: ${{ runner.os }} + # artifactName: ${{ env.ARTIFACT_NAME }} + - name: publish-tag if: ${{ github.event_name == 'pull_request' }} uses: VirtoCommerce/vc-github-actions/publish-artifact-link@master with: - artifactUrl: ${{ needs.build.outputs.imageTag}} + artifactUrl: ${{ needs.publish.outputs.tag}} repoOrg: ${{ github.repository_owner }} downloadComment: 'Image tag:' - githubToken: ${{ env.GITHUB_TOKEN }} \ No newline at end of file + githubToken: ${{ env.GITHUB_TOKEN }} \ No newline at end of file