|
| 1 | +ame: "Upload GitHub Pages artifact" |
| 2 | +description: "A composite action that prepares your static assets to be deployed to GitHub Pages" |
| 3 | +author: "GitHub" |
| 4 | +inputs: |
| 5 | + path: |
| 6 | + description: "Path of the directory containing the static assets." |
| 7 | + required: true |
| 8 | + default: "_site/" |
| 9 | + retention-days: |
| 10 | + description: "Duration after which artifact will expire in days." |
| 11 | + required: false |
| 12 | + default: "1" |
| 13 | +runs: |
| 14 | + using: composite |
| 15 | + steps: |
| 16 | + - name: Archive artifact |
| 17 | + shell: sh |
| 18 | + if: runner.os == 'Linux' |
| 19 | + run: | |
| 20 | + for f in $(chmod -c -R +r . | awk '{print substr($3, 2, length($3)-2)}') |
| 21 | + do |
| 22 | + echo "::warning::Added read permission to $f" |
| 23 | + done |
| 24 | + tar \ |
| 25 | + --dereference --hard-dereference \ |
| 26 | + --directory "$INPUT_PATH" \ |
| 27 | + -cvf "$RUNNER_TEMP/artifact.tar" \ |
| 28 | + --exclude=.git \ |
| 29 | + --exclude=.github \ |
| 30 | + . |
| 31 | + env: |
| 32 | + INPUT_PATH: ${{ inputs.path }} |
| 33 | + |
| 34 | + # Switch to gtar (GNU tar instead of bsdtar which is the default in the MacOS runners so we can use --hard-dereference) |
| 35 | + - name: Archive artifact |
| 36 | + shell: sh |
| 37 | + if: runner.os == 'macOS' |
| 38 | + run: | |
| 39 | + for f in $(chmod -v -R +r .) |
| 40 | + do |
| 41 | + echo "::warning::Added read permission to $f" |
| 42 | + done |
| 43 | + gtar \ |
| 44 | + --dereference --hard-dereference \ |
| 45 | + --directory "$INPUT_PATH" \ |
| 46 | + -cvf "$RUNNER_TEMP/artifact.tar" \ |
| 47 | + --exclude=.git \ |
| 48 | + --exclude=.github \ |
| 49 | + . |
| 50 | + env: |
| 51 | + INPUT_PATH: ${{ inputs.path }} |
| 52 | + |
| 53 | + # Massage the paths for Windows only |
| 54 | + - name: Archive artifact |
| 55 | + shell: bash |
| 56 | + if: runner.os == 'Windows' |
| 57 | + run: | |
| 58 | + tar \ |
| 59 | + --dereference --hard-dereference \ |
| 60 | + --directory "$INPUT_PATH" \ |
| 61 | + -cvf "$RUNNER_TEMP\artifact.tar" \ |
| 62 | + --exclude=.git \ |
| 63 | + --exclude=.github \ |
| 64 | + --force-local \ |
| 65 | + "." |
| 66 | + env: |
| 67 | + INPUT_PATH: ${{ inputs.path }} |
| 68 | + |
| 69 | + - name: Upload artifact |
| 70 | + uses: actions/upload-artifact@main |
| 71 | + with: |
| 72 | + name: github-pages |
| 73 | + path: ${{ runner.temp }}/artifact.tar |
| 74 | + retention-days: ${{ inputs.retention-days }} |
0 commit comments