From 027a9252fc022d095d876be36889d3653e141052 Mon Sep 17 00:00:00 2001 From: Spinochi Andreea <94178732+Andreea1503@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:08:19 +0300 Subject: [PATCH 1/2] Added test file --- .github/workflows/deploy.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index cf1594bd..7236fb09 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -6,7 +6,27 @@ on: - main jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Install dependencies + run: go mod download + + - name: Run tests + run: go test ./... + compile: + needs: test + if: success() + runs-on: ubuntu-latest steps: - name: Checkout code From c4627562c14fcb37a9cf10e0f882b571a44fc8c1 Mon Sep 17 00:00:00 2001 From: Spinochi Andreea <94178732+Andreea1503@users.noreply.github.com> Date: Tue, 15 Apr 2025 13:09:09 +0300 Subject: [PATCH 2/2] Added task 1 and task 2 --- .github/workflows/deploy.yaml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 7236fb09..dc96a150 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -42,3 +42,43 @@ jobs: - name: Compile binary run: go build -o myapp + + build: + # Specify the OS for the runner + runs-on: ubuntu-latest + + # Grant write permissions to access repository contents and GitHub Container Registry + permissions: + contents: write + packages: write + + # Run this job only after the 'compile' job is completed successfully + needs: compile + if: success() + + steps: + # Step 1: Checkout the repository code + - name: Checkout code + uses: actions/checkout@v4 + + # Step 2: Set up the Go environment (Go 1.22) + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + # Step 3: Log in to GitHub Container Registry (GHCR) using the GitHub Actions token + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} # GitHub username (actor triggering the workflow) + password: ${{ secrets.GITHUB_TOKEN }} # Automatically provided GitHub token + + # Step 4: Build the Docker image and tag it with the repository name and 'latest' + - name: Build Docker image + run: docker build -t ghcr.io/${{ github.repository }}:latest . + + # Step 5: Push the Docker image to GitHub Container Registry + - name: Push Docker image + run: docker push ghcr.io/${{ github.repository }}:latest