diff --git a/.github/actions/ciBuildAndPublishArtifact/action.yml b/.github/actions/ciBuildAndPublishArtifact/action.yml new file mode 100644 index 0000000..92afad2 --- /dev/null +++ b/.github/actions/ciBuildAndPublishArtifact/action.yml @@ -0,0 +1,28 @@ +name: "Build and publish artifact" +description: "Build and publish an artifact to github npm registery" +runs: + using: composite + steps: + - name: "Authenticate to npm" + uses: actions/setup-node@v4 + with: + registry-url: "https://npm.pkg.github.com" + + - name: "Build package" + shell: bash + run: | + sfp build --devhubalias devhub --diffcheck --buildnumber ${GITHUB_RUN_ID} --branch ${GITHUB_REF#refs/heads/} + + - name: "Publish" + shell: bash + run: | + sfp publish --artifactdir artifacts --npm --scope @${{ github.repository_owner }} --gittag --pushgittag + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - uses: navikt/sf-platform/.github/actions/uploadWorkflowArtifactsAndLogs@main + with: + artifactName: "build-artifacts" + uploadArtifacts: true + logName: "logs" + publishLogs: true diff --git a/.github/actions/uploadWorkflowArtifactsAndLogs/action.yml b/.github/actions/uploadWorkflowArtifactsAndLogs/action.yml new file mode 100644 index 0000000..38ed9aa --- /dev/null +++ b/.github/actions/uploadWorkflowArtifactsAndLogs/action.yml @@ -0,0 +1,35 @@ +name: "Upload workflow artifacts and logs" +description: "Uploads logs and sfp generated artifacts to the workflow" +inputs: + artifactName: + description: "Name of the artifact" + required: true + uploadArtifacts: + description: "If true upload the artifacts" + required: true + logName: + description: "Name of the logs" + required: true + publishLogs: + description: "If true upload the flxbl logs" + required: true +runs: + using: composite + steps: + - name: "Publish artifacts" + if: ${{ inputs.uploadArtifacts }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.logName }} + path: artifacts + retention-days: 10 + + # Upload Flxbl logs + - name: "Publish logs" + if: ${{ inputs.publishLogs }} + uses: actions/upload-artifact@v4 + with: + name: "${{ inputs.logName }}" + path: .sfpowerscripts + if-no-files-found: ignore + retention-days: 1 diff --git a/.github/workflows/ciBuild.yml b/.github/workflows/ciBuild.yml index 19f3c3c..8c657cf 100644 --- a/.github/workflows/ciBuild.yml +++ b/.github/workflows/ciBuild.yml @@ -30,34 +30,36 @@ jobs: alias: devhub setDefaultDevhubUsername: true - - name: "Build package" - run: | - sfp build --devhubalias devhub --diffcheck --buildnumber ${GITHUB_RUN_ID} --branch ${GITHUB_REF#refs/heads/} + - uses: navikt/sf-platform/.github/actions/ciBuildAndPublishArtifact@main - - name: "Publish artifacts" - if: ${{ success() }} - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: artifacts + # - name: "Build package" + # run: | + # sfp build --devhubalias devhub --diffcheck --buildnumber ${GITHUB_RUN_ID} --branch ${GITHUB_REF#refs/heads/} - - name: "Authenticate to npm" - uses: actions/setup-node@v4 - with: - registry-url: "https://npm.pkg.github.com" - - - name: "Publish" - run: | - sfp publish --artifactdir artifacts --npm --scope @${{ github.repository_owner }} --gittag --pushgittag - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # Upload Flxbl logs - - name: "Publish logs" - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: "logs" - path: .sfpowerscripts - if-no-files-found: ignore - retention-days: 1 + # - name: "Publish artifacts" + # if: ${{ success() }} + # uses: actions/upload-artifact@v4 + # with: + # name: build-artifacts + # path: artifacts + + # - name: "Authenticate to npm" + # uses: actions/setup-node@v4 + # with: + # registry-url: "https://npm.pkg.github.com" + + # - name: "Publish" + # run: | + # sfp publish --artifactdir artifacts --npm --scope @${{ github.repository_owner }} --gittag --pushgittag + # env: + # NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # # Upload Flxbl logs + # - name: "Publish logs" + # if: ${{ always() }} + # uses: actions/upload-artifact@v4 + # with: + # name: "logs" + # path: .sfpowerscripts + # if-no-files-found: ignore + # retention-days: 1