|
| 1 | +name: Test Docker Image Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + paths: |
| 7 | + - 'Dockerfile' |
| 8 | + - '.github/workflows/test-docker-image.yaml' |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-test-image: |
| 12 | + name: Build Test Image |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + id-token: write |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set lowercase owner |
| 24 | + run: echo "OWNER=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV |
| 25 | + |
| 26 | + - name: Set up Docker Buildx |
| 27 | + uses: docker/setup-buildx-action@v3 |
| 28 | + |
| 29 | + - name: Login to GitHub Container Registry |
| 30 | + uses: docker/login-action@v3 |
| 31 | + with: |
| 32 | + registry: ghcr.io |
| 33 | + username: ${{ github.actor }} |
| 34 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + |
| 36 | + - name: Build and push test image |
| 37 | + uses: docker/build-push-action@v5 |
| 38 | + with: |
| 39 | + context: . |
| 40 | + platforms: linux/amd64 |
| 41 | + push: true |
| 42 | + tags: | |
| 43 | + ghcr.io/${{ env.OWNER }}/github-runner:test |
| 44 | + ghcr.io/${{ env.OWNER }}/github-runner:test-${{ github.sha }} |
| 45 | +
|
| 46 | + verify-tools: |
| 47 | + name: Verify Pre-installed Tools |
| 48 | + needs: build-test-image |
| 49 | + runs-on: ubuntu-latest |
| 50 | + container: |
| 51 | + image: ghcr.io/${{ github.repository_owner }}/github-runner:test |
| 52 | + credentials: |
| 53 | + username: ${{ github.actor }} |
| 54 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Verify Atmos installation |
| 58 | + run: | |
| 59 | + echo "Checking Atmos..." |
| 60 | + atmos version |
| 61 | + which atmos |
| 62 | +
|
| 63 | + - name: Verify Terraform installation |
| 64 | + run: | |
| 65 | + echo "Checking Terraform..." |
| 66 | + terraform version |
| 67 | + which terraform |
| 68 | +
|
| 69 | + - name: Verify tfcmt installation |
| 70 | + run: | |
| 71 | + echo "Checking tfcmt..." |
| 72 | + tfcmt --version |
| 73 | + which tfcmt |
| 74 | +
|
| 75 | + - name: Verify terraform-docs installation |
| 76 | + run: | |
| 77 | + echo "Checking terraform-docs..." |
| 78 | + terraform-docs --version |
| 79 | + which terraform-docs |
| 80 | +
|
| 81 | + - name: Verify all tools are in PATH |
| 82 | + run: | |
| 83 | + echo "All tools verified successfully!" |
| 84 | + echo "✅ Atmos: $(atmos version | head -n 1)" |
| 85 | + echo "✅ Terraform: $(terraform version | head -n 1)" |
| 86 | + echo "✅ tfcmt: $(tfcmt --version)" |
| 87 | + echo "✅ terraform-docs: $(terraform-docs --version)" |
| 88 | +
|
| 89 | + - name: Summary |
| 90 | + if: success() |
| 91 | + run: | |
| 92 | + echo "🎉 All pre-installed tools are working correctly!" |
| 93 | + echo "The Docker image is ready to use and will avoid GitHub API rate limits." |
0 commit comments