diff --git a/github-actions/templates/bash-script.yml b/.github/bash-script.yml similarity index 91% rename from github-actions/templates/bash-script.yml rename to .github/bash-script.yml index 3c572cdde..9b43c6b0f 100644 --- a/github-actions/templates/bash-script.yml +++ b/.github/bash-script.yml @@ -1,4 +1,4 @@ -name: Run Bash Script +name: Run Bash Script Original on: push: diff --git a/.github/data.json b/.github/data.json new file mode 100644 index 000000000..e6902fcca --- /dev/null +++ b/.github/data.json @@ -0,0 +1 @@ +eyJncmVldGluZyI6ICJIZWxsbyIsICJuYW1lIjogIkNhbGkifQ== \ No newline at end of file diff --git a/github-actions/myscript.sh b/.github/my-scripts/myscript.sh similarity index 100% rename from github-actions/myscript.sh rename to .github/my-scripts/myscript.sh diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml new file mode 100644 index 000000000..fc234598c --- /dev/null +++ b/.github/workflows/artifact.yml @@ -0,0 +1,52 @@ +name: Node.js CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 'latest' + + - name: Restore Cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-npm- + + - name: Install dependencies + run: npm install + + - name: Save Cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} + + - name: Run tests + run: npm test + if: github.ref == 'refs/heads/main' + + - name: Build project + run: npm run build + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: my-app + path: dist/ \ No newline at end of file diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml new file mode 100644 index 000000000..76ebced68 --- /dev/null +++ b/.github/workflows/commands.yml @@ -0,0 +1,18 @@ +name: Commands + +on: ['push'] + +jobs: + commands: + runs-on: ubuntu-latest + steps: + - name: Exporting Var + run: | + echo "my_Var=Cali is my Name" >> $GITHUB_ENV + echo "my_Var_2=Sammy is my GF" >> $GITHUB_ENV + echo "my_Var_3=Yahoo mi password" >> $GITHUB_ENV + - name: From Exporting + run: | + echo $my_Var + echo $my_Var_2 + echo $my_Var_3 \ No newline at end of file diff --git a/.github/workflows/conditional-if-or.yml b/.github/workflows/conditional-if-or.yml new file mode 100644 index 000000000..2071117d1 --- /dev/null +++ b/.github/workflows/conditional-if-or.yml @@ -0,0 +1,15 @@ +name: Conditional If Equal Or +# since this time is including an or for my repo it will run as opossed to conditonal.yml +on: [push] +jobs: + hello-world: + if: github.repository == 'octo-org/octo-repo-prod' || github.repository == 'Cert-Organization/Github-Examples' + runs-on: ubuntu-latest + steps: + - name: "Hello World" + run: echo "Hello World!" + goodbye-moon: + runs-on: ubuntu-latest + steps: + - name: "Goodbye Moon" + run: echo "Goodbye Moon!" \ No newline at end of file diff --git a/github-actions/templates/conditional.yml b/.github/workflows/conditional.yml similarity index 91% rename from github-actions/templates/conditional.yml rename to .github/workflows/conditional.yml index 87b48c2f9..ab1788fa1 100644 --- a/github-actions/templates/conditional.yml +++ b/.github/workflows/conditional.yml @@ -1,4 +1,4 @@ -name: example-workflow +name: Conditional If Equal on: [push] jobs: hello-world: diff --git a/.github/workflows/contexts.yml b/.github/workflows/contexts.yml new file mode 100644 index 000000000..3581457ed --- /dev/null +++ b/.github/workflows/contexts.yml @@ -0,0 +1,17 @@ +name: Contexts + +on: ['push'] + +jobs: + my_contexts: + runs-on: ubuntu-latest ## https://docs.github.com/en/actions/learn-github-actions/contexts#github-context ## + steps: + - name: myContexts + run: | + echo "Action next: $MY_ACTION" + env: + MY_ACTION: ${{github.action}} + MY_REPO: ${{ github.action_repository }} + MY_ACTOR: ${{ github.actor }} + MY_REPO_OWNER: ${{ github.repository_owner }} + MY_REPO_URL: ${{ github.repositoryUrl }} diff --git a/.github/workflows/custom-action.yml b/.github/workflows/custom-action.yml index 7a87b53f1..23d130678 100644 --- a/.github/workflows/custom-action.yml +++ b/.github/workflows/custom-action.yml @@ -1,3 +1,5 @@ +name: Custom + on: [push] jobs: diff --git a/github-actions/templates/dependent-jobs.yml b/.github/workflows/dependent-jobs.yml similarity index 67% rename from github-actions/templates/dependent-jobs.yml rename to .github/workflows/dependent-jobs.yml index 6c6a1752a..42029f9dc 100644 --- a/github-actions/templates/dependent-jobs.yml +++ b/.github/workflows/dependent-jobs.yml @@ -1,4 +1,4 @@ -name: Build, Test, and Deploy Workflow +name: Dependant Jobs 1 Build, Test, and Deploy Workflow on: push: @@ -7,22 +7,32 @@ on: jobs: deploy: - needs: [build, test] + needs: [packaging, build, test] runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Deploy application run: echo "Deploying to production..." - build: + test: + needs: build runs-on: ubuntu-latest steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Test application + run: echo "Running tests..." + + build: + needs: packaging + runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v3 - name: Build application run: echo "Building the application..." - test: - needs: build + + packaging: runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.github/workflows/dependent-jobs_2.yml b/.github/workflows/dependent-jobs_2.yml new file mode 100644 index 000000000..c6c8c87bc --- /dev/null +++ b/.github/workflows/dependent-jobs_2.yml @@ -0,0 +1,42 @@ +name: Dependant Jobs 2 Build, Test, and Deploy Workflow + +on: + push: + branches: + - main + +jobs: + + packaging: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Test application + run: echo "Running tests..." + test: + needs: packaging + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Test application + run: echo "Running tests..." + + build: + needs: packaging + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Build application + run: echo "Building the application..." + + deploy: + needs: [build, test] + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Deploy application + run: echo "Deploying to production..." diff --git a/github-actions/templates/expression-functions.yml b/.github/workflows/expression-functions.yml similarity index 64% rename from github-actions/templates/expression-functions.yml rename to .github/workflows/expression-functions.yml index e213a386b..82fddedb5 100644 --- a/github-actions/templates/expression-functions.yml +++ b/.github/workflows/expression-functions.yml @@ -1,4 +1,4 @@ -name: Expression Functions Demo +name: Expression Functions on: push: @@ -24,14 +24,20 @@ jobs: run: echo ${{ format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat') }} - name: Join issue labels if: github.event_name == 'issues' - run: echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}" + run: | + echo "Issue labels: ${{ join(github.event.issue.labels.*.name, ', ') }}" - name: Convert job context to JSON - run: echo "Job context in JSON: ${{ toJSON(github.job) }}" + run: | + echo "Job context in JSON: ${{ toJSON(github.job) }}" - name: Parse JSON string - run: echo "Parsed JSON: ${{ fromJSON('{"hello":"world"}').hello }}" + run: | + echo "Parsed JSON: ${{ fromJSON('{"hello":"world"}').hello }}" - name: Hash files - run: echo "Hash of files: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }} + run: | + echo "Hash of files: ${{ hashFiles('**/package-lock.json', '**/Gemfile.lock') }}" - name: The job has succeeded if: ${{ success() }} + run: echo "The job has succeeded." - name: The job has failed - if: ${{ failure() }} \ No newline at end of file + if: ${{ failure() }} + run: echo "The job has failed." \ No newline at end of file diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 000000000..1f2deb541 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,22 @@ +name: Couple♡ ♡ ♡ + +on: + workflow_dispatch: + inputs: + novio: + description: 'Nombre del Novio' + required: true + type: string + novia: + description: 'Nombre del Novia' + required: true + type: string + +jobs: + MensajedeAmor: + runs-on: ubuntu-latest + steps: + - name: Mensaje de Amor + run: | + echo "${{ inputs.novio}} y ${{ inputs.novia }}!" + echo -e "\033[31m♡ ♡ ♡ \033[1m${{ inputs.novia }} ES MI NOVIA Y LA QUIERO MUCHO ♡ ♡ ♡\033[0m" diff --git a/github-actions/templates/multi-event.yml b/.github/workflows/multi-event.yml similarity index 94% rename from github-actions/templates/multi-event.yml rename to .github/workflows/multi-event.yml index a3275be38..a4abd337a 100644 --- a/github-actions/templates/multi-event.yml +++ b/.github/workflows/multi-event.yml @@ -1,3 +1,5 @@ +name: Multi-Event + on: push: branches: diff --git a/.github/workflows/outputs-jobs.yml b/.github/workflows/outputs-jobs.yml new file mode 100644 index 000000000..7f1217947 --- /dev/null +++ b/.github/workflows/outputs-jobs.yml @@ -0,0 +1,24 @@ +name: Jobs and Outputs + +on: + push: + +jobs: + random-number-generator: + runs-on: ubuntu-latest + outputs: + number: ${{ steps.generate-number.outputs.number }} + steps: + - name: Generate number + id: generate-number + run: echo "number=$RANDOM" >> $GITHUB_OUTPUT + + consumer-of-generator: + needs: random-number-generator + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use generated number + run: echo "The number is ${{ needs.random-number-generator.outputs.number }}" \ No newline at end of file diff --git a/.github/workflows/outputs-steps.yml b/.github/workflows/outputs-steps.yml new file mode 100644 index 000000000..c4bb471cf --- /dev/null +++ b/.github/workflows/outputs-steps.yml @@ -0,0 +1,20 @@ +name: Steps and Outputs + +on: + push: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Generate number + id: generate-number + run: echo "number=$RANDOM" >> $GITHUB_OUTPUT + + - name: Use number + id: use-number + run: echo "The number is ${{ steps.generate-number.outputs.number }}" \ No newline at end of file diff --git a/github-actions/templates/schedule.yml b/.github/workflows/schedule.yml similarity index 61% rename from github-actions/templates/schedule.yml rename to .github/workflows/schedule.yml index a88231de6..70c691fa8 100644 --- a/github-actions/templates/schedule.yml +++ b/.github/workflows/schedule.yml @@ -1,10 +1,12 @@ +name: Schedule + on: schedule: - - cron: '*/5 * * * *' + - cron: '0 */4 * * *' jobs: hello_world: runs-on: ubuntu-latest steps: - - name: Echo current time + - name: Echo current time is now run: echo "The current server time is $(date)" diff --git a/.github/workflows/variables-ENV.yml b/.github/workflows/variables-ENV.yml new file mode 100644 index 000000000..5a209ef78 --- /dev/null +++ b/.github/workflows/variables-ENV.yml @@ -0,0 +1,20 @@ +name: Using ENV global, job and step +# using ENV variables in different locations Global, Job and Step + +on: ['push'] + +env: + globalEnvDay: Monday +jobs: + usingEnvVariables: + runs-on: ubuntu-latest + env: + jobEnvDay: "Tuesday" + steps: + - name: Exporting Var + env: + stepEnvDay: "Webnesday" + run: | + echo "Firt Day: $globalEnvDay" + echo "Second Day: $jobEnvDay" + echo "Firt Day: $stepEnvDay" diff --git a/github-actions/templates/webhook.yml b/.github/workflows/webhook.yml similarity index 62% rename from github-actions/templates/webhook.yml rename to .github/workflows/webhook.yml index dbdf1e47d..94037d484 100644 --- a/github-actions/templates/webhook.yml +++ b/.github/workflows/webhook.yml @@ -1,4 +1,4 @@ -name: "Webhook Event example" +name: "Webhook Event" on: repository_dispatch: @@ -9,7 +9,8 @@ jobs: respond-to-dispatch: runs-on: ubuntu-latest steps: - - name Checkout repo + - name: Checkout repo uses: actions/checkout@v2 - name: Run a script - run: echo "Event of type: $GITHUB_EVENT_NAME" + run: | + echo "Event Type" $GITHUB_EVENT_NAME \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..b242572ef --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ] +} \ No newline at end of file diff --git a/github-actions/templates/greetings.yml b/github-actions/templates/greetings.yml index 996da6bbd..f4a82faf2 100644 --- a/github-actions/templates/greetings.yml +++ b/github-actions/templates/greetings.yml @@ -1,3 +1,4 @@ +# Adding my comment 34 name: Greetings on: [pull_request_target, issues] diff --git a/github-actions/templates/manual.yml b/github-actions/templates/manual.yml deleted file mode 100644 index 081adf3a6..000000000 --- a/github-actions/templates/manual.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Manual Trigger with Params - -on: - workflow_dispatch: - inputs: - name: - description: 'Name of the person to greet' - required: true - type: string - greeting: - description: 'Type of greeting' - required: true - type: string - data: - description: 'Base64 encoded content of a file' - required: false - type: string - -jobs: - greet: - runs-on: ubuntu-latest - steps: - - name: Decode File Content - run: | - echo "${{ inputs.data }}" | base64 --decode > ./decoded_file.txt - - name: Display Greeting - run: | - echo "${{ inputs.greeting }}, ${{ inputs.name }}!" - - name: Display File Content - run: | - echo "Contents of the file:" - cat ./decoded_file.txt \ No newline at end of file