Skip to content

Instantly share code, notes, and snippets.

@sephraim
Last active August 21, 2024 21:01
Show Gist options
  • Save sephraim/fc0d5df5b90edfc3fa40246c605c64dd to your computer and use it in GitHub Desktop.
Save sephraim/fc0d5df5b90edfc3fa40246c605c64dd to your computer and use it in GitHub Desktop.
[GitHub Actions - Upload artifacts]
# FILE: .github/workflows/upload-artifacts.yml
name: Upload artifacts on failure
on:
push:
branches:
- main
- master
- develop
paths:
- "**.yml"
- "**.yaml"
pull_request:
branches:
- main
- master
- develop
paths:
- "**.yml"
- "**.yaml"
jobs:
Upload:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create some random text files
run: |
echo "Hello, world!" > random-root-file.txt
echo "Hello, world!" > ${{ runner.temp }}/random-temp-file.txt
- name: Fail purposely so files get uploaded as artifacts
run: exit 1
- name: Upload file 1
if: failure()
uses: actions/upload-artifact@v4
with:
name: file1.txt
path: random-root-file.txt
retention-days: 14
- name: Upload file 2
if: failure()
uses: actions/upload-artifact@v4
with:
name: file2.txt
path: ${{ runner.temp }}/random-temp-file.txt
retention-days: 14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment