Skip to content

Improving readme

Improving readme #79

Workflow file for this run

name: 'Test action'
on:
push:
branches:
- master
paths-ignore:
- 'README.md'
- '.vscode/**'
pull_request:
branches:
- master
- development
env:
tag_for_tests: Test-${{ github.head_ref || github.ref || github.sha }}
jobs:
build:
if: github.repository == 'Xotl/cool-github-releases'
name: 'Build dist for testing'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build the Docker image
run: docker build --target builder -t gh-action-builder .
- name: Generate new dist folder & files
run: |
mkdir new-dist
docker run --rm -v ${PWD}/new-dist:/usr/src/app/dist gh-action-builder
- name: Save dist folder
uses: actions/upload-artifact@v4
with:
name: dist-test
path: ./new-dist/
tests:
runs-on: ubuntu-latest
name: Test action modes
needs: build
env:
TEST_TEXT: "Asset replaced correctly"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Delete old dist
run: rm -rf dist
- name: Download dist from build job
uses: actions/download-artifact@v4
with:
name: dist-test
path: dist/
- name: Prepare files for tests
run: |
echo "${{env.TEST_TEXT}}" > "./src/README.md"
- name: It should create a release with assets README.md and LICENCE
id: test_create
uses: ./ # Uses the action in the root directory
with:
mode: update
isPrerelease: true
tag_name: ${{ env.tag_for_tests }}
release_name: Testing release action
body_mrkdwn: "### It works!\n Wow, it worked like a charm 🎉"
assets: README.md;LICENSE|text/plain;
github_token: ${{ github.token }}
- name: It should edit release name, add asset build.yml & replace README.md with a new one
uses: ./ # Uses the action in the root directory
with:
mode: update
isPrerelease: true
replace_assets: true
releaseId: ${{ steps.test_create.outputs.releaseId }}
release_name: Testing edit of a release
assets: .github/workflows/build.yml;src/README.md
github_token: ${{ github.token }}
- name: It should download assets README.md, LICENCE, build.yml from Test release
uses: ./ # Uses the action in the root directory
with:
tag_name: ${{ env.tag_for_tests }}
assets: README.md|dowloaded_README.md;LICENSE|non-existant-folder/LICENSE;build.yml
github_token: ${{ github.token }}
- name: Confirm that files are correct
run: |
if [ "$(cat dowloaded_README.md)" != "${{env.TEST_TEXT}}" ]; then exit 1; fi
if [ "$(cat non-existant-folder/LICENSE)" != "$(cat LICENSE)" ]; then exit 1; fi
if [ "$(cat build.yml)" != "$(cat .github/workflows/build.yml)" ]; then exit 1; fi
- name: It should download asset cards.json from repo hay-espacio-en-el-taco/dbs-scraper
uses: ./ # Uses the action in the root directory
with:
assets: cards.json|dowloaded_cards.json
github_token: ${{ secrets.DBS_SCRAPER_TOKEN }}
repository: hay-espacio-en-el-taco/dbs-scraper
- name: Confirm that downloaded files are correct
run: |
actualsize=$(wc -c < "dowloaded_cards.json")
echo "${actualsize}"
if [ ! -f dowloaded_cards.json ] || [ ! $actualsize -ge 3000000 ]; then
exit 1;
fi
- name: It should delete release with tag Test
uses: ./ # Uses the action in the root directory
if: ${{ always() }} # This will help to run the next test without manually deleting every time
with:
mode: delete
tag_name: ${{ env.tag_for_tests }}
github_token: ${{ github.token }}
deploy_start:
# This job will trigger the actual build & deploy workflow
if: github.ref == 'refs/heads/master'
name: Trigger deploy
uses: ./.github/workflows/build.yml
needs: tests
secrets: inherit