Add files via upload #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Data Assets to Release with Pseudo-Pastas | |
| # Dispara o workflow quando qualquer arquivo dentro da pasta data muda na branch main | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'data/**' | |
| jobs: | |
| update-release: | |
| runs-on: ubuntu-latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.MY_PAT }} # <- Use aqui seu PAT criado como secret | |
| steps: | |
| # 1️⃣ Clona o repositório | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # 2️⃣ Cria ou atualiza a Release | |
| - name: Create or update Release | |
| id: release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v1.0 # Substitua se quiser outra tag | |
| # 3️⃣ Upload de todos os arquivos dentro da pasta data mantendo pseudo-pastas | |
| - name: Upload all data files | |
| run: | | |
| shopt -s globstar | |
| for file in data/**/*; do | |
| if [ -f "$file" ]; then | |
| # Remove "data/" do caminho para criar pseudo-pasta no asset | |
| asset_name="${file#data/}" | |
| echo "Uploading $file as $asset_name" | |
| gh release upload "v1.0" "$file" --clobber --name "$asset_name" | |
| fi | |
| done | |