test: ci #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Docker image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- test/ci | ||
env: | ||
REGISTRY: docker.io | ||
IMAGE_NAME: OsmanthusBeer/api-beer | ||
PORT: 40000 | ||
jobs: | ||
push_to_registry: | ||
name: Push Docker image to Docker Hub | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
- name: Log into GitHub Container Registry | ||
# TODO: Create a PAT with `read:packages` and `write:packages` scopes and save it as an Actions secret `CR_PAT` | ||
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin | ||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||
with: | ||
images: enyajump/api-beer | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
- name: Server Start | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.REMOTE_HOST }} | ||
username: ${{ secrets.REMOTE_USERNAME }} | ||
key: ${{ secrets.REMOTE_PRIVATE_KEY }} | ||
script: | | ||
Check failure on line 46 in .github/workflows/build.yml GitHub Actions / Publish Docker imageInvalid workflow file
|
||
echo ${{ secrets.$CR_PAT }} | docker login ghcr.io -u USERNAME --password-stdin | ||
docker pull ${{ steps.meta.outputs.tags }} | ||
docker stop ${{ env.IMAGE_NAME }} || echo "stop container [${{ env.IMAGE_NAME}}] error" | ||
docker rm ${{ env.IMAGE_NAME }} || echo "delete container [${{ env.IMAGE_NAME}}] error" | ||
docker run -d -p ${{ env.PORT }}:3000 --name ${{ env.IMAGE_NAME }} -it ${{ steps.meta.outputs.tags }} |