56 lines
1.3 KiB
YAML
56 lines
1.3 KiB
YAML
# For information on GITHUB_TOKEN: https://docs.github.com/en/actions/concepts/security/github_token
|
|
# For information on github.actor: https://github.com/orgs/community/discussions/62108
|
|
|
|
name: Build and Deploy
|
|
|
|
on:
|
|
pull_request:
|
|
branches: ["main"]
|
|
push:
|
|
branches: ["main"]
|
|
|
|
env:
|
|
CONTAINER_NAME: codered-astra
|
|
CONTAINER_TAG: ghcr.io/${{ github.repository_owner }}/codered-astra:latest
|
|
|
|
jobs:
|
|
# Set permissions for the job
|
|
build:
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
|
|
name: Build Docker Image
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }} # User that commits
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
|
|
with:
|
|
context: .
|
|
platforms: linux/amd64
|
|
push: true
|
|
tags: ${{ env.CONTAINER_TAG }}
|
|
|
|
# WIP: For deployment
|
|
deploy:
|
|
name: Deploy Docker Image to Server
|
|
runs-on: self-hosted
|
|
needs: build
|
|
steps:
|