Created
September 9, 2023 19:49
-
-
Save tk42/d9f772b84bc0a62d28b94877f5a6d2c0 to your computer and use it in GitHub Desktop.
.github/workflows/deploy.yml
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: Deploy | |
on: | |
push: | |
branches: [main] | |
jobs: | |
deploy: | |
env: | |
GIT_TERMINAL_PROMPT: 1 | |
runs-on: ubuntu-latest | |
steps: | |
- name: github private modules access | |
run: git config --global url."https://${{ secrets.PAT }}:[email protected]/".insteadOf "https://github.com/" | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
- name: Set up cache | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- uses: docker/setup-buildx-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# If this fails due to 403 Forbidden, you'll check https://github.com/docker/build-push-action/issues/463#issuecomment-924995909 | |
- uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest |
最初のdeploy(push image)が失敗する時,レポジトリのSettings->Actions->General->Workflow permissionsでRead and write permissions にチェックが入っているか確認
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Githubの
Organization
→Settings
→Secrets and variables
→Actions
にPAT
というSecretsを登録しておいて,Dockerfileをレポジトリのルートに含むレポジトリで,.github/workflows以下に上記をdeploy.ymlとしておくと,mainブランチにpushされるごとにイメージを作ってくれる