diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml new file mode 100644 index 0000000..a4c5a22 --- /dev/null +++ b/.github/workflows/artifacts.yml @@ -0,0 +1,15 @@ +name: Artifacts + +on: [pull_request] + +jobs: + artifact-upload: + runs-on: ubuntu-latest + steps: + - run: echo "Demo file" > demo.txt + + - name: Upload demo file + uses: actions/upload-artifact@v4 + with: + name: demo-artifact + path: demo.txt diff --git a/.github/workflows/concurrency.yml b/.github/workflows/concurrency.yml new file mode 100644 index 0000000..827c8c8 --- /dev/null +++ b/.github/workflows/concurrency.yml @@ -0,0 +1,18 @@ +name: Concurrency + +on: [pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + exclusive-run: + runs-on: ubuntu-latest + steps: + - name: Slow step + run: | + echo "Starting..." + # Simulate setup time + sleep 120 + echo "Finished" diff --git a/.github/workflows/dependent.yml b/.github/workflows/dependent.yml new file mode 100644 index 0000000..3e00658 --- /dev/null +++ b/.github/workflows/dependent.yml @@ -0,0 +1,47 @@ +name: Dependent + +on: [pull_request] + +jobs: + setup-db: + runs-on: ubuntu-latest + steps: + - name: Setup Database + run: | + echo "Setting up database..." + # Simulate setup time + sleep 5 + echo "Database ready." + + - name: Initialize DB Schema + run: echo "Initializing DB schema after setup." + + lint-code: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Run Linter + run: echo "Running linter on codebase..." + + build-and-test: + runs-on: ubuntu-latest + needs: [setup-db, lint-code] # This job waits for both setup-db and lint-code + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build project + run: echo "Building project..." + + - name: Run tests + run: echo "Running tests..." + + deploy: + runs-on: ubuntu-latest + needs: build-and-test + environment: production + steps: + - name: Deploy app + run: echo "Deploying app to production..." diff --git a/.github/workflows/env-vars.yml b/.github/workflows/env-vars.yml new file mode 100644 index 0000000..0cea51f --- /dev/null +++ b/.github/workflows/env-vars.yml @@ -0,0 +1,16 @@ +name: Environment Variables +on: [pull_request] + +env: + DAY_OF_WEEK: Monday + +jobs: + env-vars: + runs-on: ubuntu-latest + env: + Greeting: Hello + steps: + - name: "Say Hello Mona it's Monday" + run: echo "$Greeting $First_Name. Today is $DAY_OF_WEEK!" + env: + First_Name: Mona diff --git a/.github/workflows/github-token.yml b/.github/workflows/github-token.yml new file mode 100644 index 0000000..441d7ad --- /dev/null +++ b/.github/workflows/github-token.yml @@ -0,0 +1,21 @@ +name: GitHub Token + +on: [pull_request] +permissions: + pull-requests: write # Needed to post comments + +jobs: + comment-pr: + runs-on: ubuntu-latest + + steps: + - name: Comment on PR + uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: "👋 Hello from `actions/github-script`!" + }); diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 0000000..a1cff2a --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,37 @@ +name: Manual + +on: + workflow_dispatch: + inputs: + environment: + description: "Target environment" + required: true + default: "staging" + type: choice + options: + - staging + - production + - preview + + dry_run: + description: "Run without deploying" + required: false + default: false + type: boolean + + custom_message: + description: "Custom deployment message" + required: false + default: "Triggered manually" + type: string + +jobs: + manual-run: + runs-on: ubuntu-latest + + steps: + - name: Show Inputs + run: | + echo "Deploying to: ${{ github.event.inputs.environment }}" + echo "Dry run: ${{ github.event.inputs.dry_run }}" + echo "Message: ${{ github.event.inputs.custom_message }}" diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml new file mode 100644 index 0000000..8827bda --- /dev/null +++ b/.github/workflows/matrix.yml @@ -0,0 +1,13 @@ +name: Matrix + +on: [pull_request] + +jobs: + matrix-example: + runs-on: ubuntu-latest + strategy: + matrix: + version: [1, 2, 3] + language: [node, java] + steps: + - run: echo "Testing language ${{ matrix.language }} version ${{ matrix.version }}" diff --git a/.github/workflows/outputs.yml b/.github/workflows/outputs.yml new file mode 100644 index 0000000..49272d8 --- /dev/null +++ b/.github/workflows/outputs.yml @@ -0,0 +1,22 @@ +name: Outputs + +on: [pull_request] + +jobs: + generate-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.set-version.outputs.version }} + steps: + - name: Set version output + id: set-version + run: | + VERSION="v1.2.3" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + use-version: + runs-on: ubuntu-latest + needs: generate-version + steps: + - name: Use the version from previous job + run: echo "Deploying version ${{ needs.generate-version.outputs.version }}" diff --git a/.github/workflows/secrets.yml b/.github/workflows/secrets.yml new file mode 100644 index 0000000..1fcdc1f --- /dev/null +++ b/.github/workflows/secrets.yml @@ -0,0 +1,11 @@ +name: Secrets and Variables + +on: [pull_request] + +jobs: + secrets-variables: + runs-on: ubuntu-latest + + steps: + - name: Call api + run: echo "calling ${{ vars.API_URL }} with key ${{ secrets.API_KEY }}" diff --git a/.github/workflows/services.yml b/.github/workflows/services.yml new file mode 100644 index 0000000..a47ebdd --- /dev/null +++ b/.github/workflows/services.yml @@ -0,0 +1,24 @@ +name: Services +on: [pull_request] + +jobs: + test-with-db: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: user + POSTGRES_PASSWORD: pass + POSTGRES_DB: testdb + ports: + - 5432:5432 + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - run: echo "Would run tests using PostgreSQL service" diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..0b159c8 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,11 @@ +name: Testing + +on: [pull_request] + +jobs: + checkout: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v4