|
| 1 | +name: Deploy to production |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "master" ] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + IMAGE_NAME: ${{ github.repository }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Setup Docker buildx |
| 23 | + uses: docker/setup-buildx-action@v2.4.1 |
| 24 | + |
| 25 | + # Login against a Docker registry |
| 26 | + - name: Log into registry ${{ env.REGISTRY }} |
| 27 | + uses: docker/login-action@v2.1.0 |
| 28 | + with: |
| 29 | + registry: ${{ env.REGISTRY }} |
| 30 | + username: ${{ github.actor }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + # Extract metadata (tags, labels) for Docker |
| 34 | + - name: Extract Docker metadata |
| 35 | + id: meta |
| 36 | + uses: docker/metadata-action@v4.3.0 |
| 37 | + with: |
| 38 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 39 | + |
| 40 | + # Build and push Docker image with Buildx |
| 41 | + - name: Build and push Docker image |
| 42 | + id: build-and-push |
| 43 | + uses: docker/build-push-action@v4.0.0 |
| 44 | + with: |
| 45 | + file: ./Dockerfile |
| 46 | + tags: ${{ steps.meta.outputs.tags }} |
| 47 | + labels: ${{ steps.meta.outputs.labels }} |
| 48 | + |
| 49 | + - name: Install kubectl |
| 50 | + run: | |
| 51 | + wget "https://dl.k8s.io/release/$(wget -qO- https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl" |
| 52 | + chmod +x kubectl |
| 53 | + mv kubectl /usr/local/bin |
0 commit comments