Google Drive Logo

GitHub Actions data jobs

Create a New Console Project I am going to create a dotnet project to demonstrate this, but it is applicable for all other programming languages as well Open any folder, then open Terminal In Terminal, create a new dotnet console project using the below command 1 2 3 4 5 6 7 8 dotnet new console -n GitCiCd cd .\GitCiCd\ code . mkdir .github cd .\.github\ mkdir workflows cd .\workflows\ echo "" > "dotnet.yaml" In dotnet.yaml file Paste Below Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 name: workflows on: push: branches: [ "master" ] jobs: scrape_videos: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Set up .NET uses: actions/setup-dotnet@v2 with: dotnet-version: '8.0.x' # Use the latest .NET version - name: Restore dependencies run: dotnet restore - name: Build the project run: dotnet build --configuration Release - name: Run the scraping script run: dotnet run --project GetYoutubeVideo.csproj - name: Commit and Push Changes run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add Text.txt git commit -m "Update Text.txt list" git push Inside Program.cs file paste below code for. 1 2 3 4 5 6 7 8 9 10 11 var ls = Enumerable.Range(1,8).Select(i => i.ToString() + DateTime.Now).ToList(); SaveToFile(ls, "Text.txt"); static void SaveToFile(List<string> videos, string filePath) { using StreamWriter file = new(filePath); foreach (var video in videos) { file.WriteLine(video); } } The code Responsible for operation is below code 1 2 3 4 5 6 7 - name: Commit and Push Changes run: | git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git add Text.txt git commit -m "Update Text.txt list" git push Push to github Now Go to Repository Setting Tab ...

July 28, 2024 · 2 min · 356 words · PrashantUnity