Skip to content

持續整合

Github action

make is ok tests/auto_test.sh: line 7: virtualenv: command not found

``` = name: Github Actions CI

on: push: branches: [ develop, feature/, hotfix/ ]

jobs: build: runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v2
  - name: Set up Python 3.9
    uses: actions/setup-python@v2
    with:
      python-version: 3.9
  - name: Build RDS/Reddis/ElasticSearch by docker-compose
    run: |
      cd test_tools/docker-compose
      docker-compose up -d
  - name: Install dependencies
    run: |
      pip install --upgrade pip
      pip install -r portal/djangoprojects/mysite/requirements.txt
      pip install -r portal/djangoprojects/mysite/unit_test_requirements.txt
  - name: Run Tests
    run: |
      cd portal/djangoprojects/mysite/
      python manage.py test --exclude-tag=aws

```

Execute job in a workflow only if some file in a subfolder is changed

yaml= jobs: # JOB to run change detection changes: runs-on: ubuntu-latest # Set job outputs to values from filter step outputs: backend: ${{ steps.filter.outputs.backend }} frontend: ${{ steps.filter.outputs.frontend }} steps: # For pull requests it's not necessary to checkout the code - uses: dorny/paths-filter@v2 id: filter with: filters: | backend: - 'backend/**' frontend: - 'frontend/**' # JOB to build and test backend code backend: needs: changes if: ${{ needs.changes.outputs.backend == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - ... # JOB to build and test frontend code frontend: needs: changes if: ${{ needs.changes.outputs.frontend == 'true' }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - ...

mysql

Configuring OpenID Connect in Amazon Web Services

Edit the trust relationship in IAM Role setting to add the sub field to the validation conditions

"Condition": {"StringLike": {"token.actions.githubusercontent.com:sub": "repo:github_account/repo_name:*"}}

for any repo in your GitHub account

token.actions.githubusercontent.com:sub: repo:github_account/*

scoped to a specific branch

token.actions.githubusercontent.com:sub: repo:github_account/*:ref:refs/heads/main

multiple repos

"Condition": {"StringLike": {"token.actions.githubusercontent.com:sub": [
        "repo:github_account_1/repo_name:*",
        "repo:github_account_2/repo_name:*",
        "repo:github_account_3/repo_name:*"
      ]}}

total example

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::999999999999:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
                },
                "StringLike": {
                    "token.actions.githubusercontent.com:sub": [
                        "repo:Tom/*:*",
                        "repo:Jimmy/*:*",
                        "repo:Mary/*:*"
                    ]
                }
            }
        }
    ]
}

docker compose

docker inspect <docker id or name> | grep com.docker.compose

Gitlab