diff --git a/.github/workflows/ex3_interact_with_github_api.yaml b/.github/workflows/ex3_interact_with_github_api.yaml new file mode 100644 index 0000000..8dc36ee --- /dev/null +++ b/.github/workflows/ex3_interact_with_github_api.yaml @@ -0,0 +1,32 @@ +name: interact with Github API +on: + pull_request: + +jobs: + create-issue: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Install curl + shell: bash + run: | + sudo apt update && sudo apt install curl -y + - name: Shorten SHA + id: short_sha + env: + SHA: ${{ github.sha }} + run: echo "sha_short=${SHA::7}" >> "$GITHUB_ENV" + - name: Request Github API + shell: bash + run: | + echo "https://api.github.com/repos/${{ github.repository }}/issues" + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/issues \ + --header 'authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "title": "Automated issue for commit: ${{ env.sha_short }}", + "body": "This issue was automatically created by the GitHub Action workflow **${{ github.workflow }}**. \n\n The commit hash was: _${{ env.sha_short }}_." + }' \ + --fail diff --git a/.github/workflows/ex3_switch_node_version.yaml b/.github/workflows/ex3_switch_node_version.yaml new file mode 100644 index 0000000..ced741d --- /dev/null +++ b/.github/workflows/ex3_switch_node_version.yaml @@ -0,0 +1,24 @@ +name: Switch Node version +on: + pull_request: + +jobs: + run-npm-test: + runs-on: ubuntu-latest + env: + NODE_VERSION: '14' + steps: + - name: checkout + uses: actions/checkout@v3 + - name : setup node + uses: actions/setup-node@v3 + with: + node-version: "${{ env.NODE_VERSION }}" + - name: run test + shell: bash + run: | + npm install + npm test + - name: show node version + shell: bash + run: node -v \ No newline at end of file